Reputation: 225
I seem to be getting this error when I'm trying to import the scanner package and I can't figure out why.
Here is my script.
package week.pkg1;
public class Week1 {
import java.util.Scanner;
public static void main(String[] args) {
String setName = null;
Integer setAge = null;
Double SetWeight = null;
Double setHeight = null;
System.out.println("*********************************************");
System.out.println("* Welcome to GymsRUs Health Application *");
System.out.println("* Version 1.0 *");
System.out.println("* CIS355A *");
System.out.println("*********************************************");
System.out.println("");
System.out.println("");
System.out.println("");
System.out.print("Please Input Name: ");
setName =
}
}
Any help would greatly be appreciated.
*Code added in frame.
Upvotes: 1
Views: 2078
Reputation: 49
1 - Import statement should be below to package and above class declaration.
ex-
package week.pkg1;
import java.util.Scanner;
public class Week1 {
public static void main(String[] args) {
2- The setName =
is also not a valid statement.
Upvotes: 0
Reputation:
Remove import line and then just click CTRL+SHIFT+I. It will add a class from a specific package into a proper place of code.
Upvotes: 0
Reputation: 140475
Imports must happen before any class declarations!
Simply move any import directly after the package declaration; and your problem should be solved.
Upvotes: 1