Results 1 to 3 of 3
Thread: Simple error help
- 12-28-2012, 08:46 PM #1
Member
- Join Date
- Dec 2012
- Posts
- 2
- Rep Power
- 0
Simple error help
I am following an online course on the basics of java. right now im trying to learn Scanner class works.
i have my code written exactly as it says in the example, but i am getting error messages.
-Syntax error on token "importjava", package expected before this token
-The import java.util.Scanner conflicts with a type defined in the same file
-The constructor Scanner (InputStream) is undefined
-The method next() is undefined for the type Scanner
-Line breakpoint:Scanner [line:14] - main(string[])
import java.util.Scanner;
public class Scanner {
public static void main(String[] args) {
Scanner user_input = new Scanner(System.in);
String First_name;
System.out.print("enter your first name :");
First_name = user_input.next();
String Family_name;
System.out.print("enter your family name :");
String Full_name;
Full_name = First_name + " " + Family_name;
System.out.println("You are" + Full_name);
}
}
im sure the problem is very easy to solve, but i am just too new to this to figure it out. i may have missed something in the example...but i have looked it over several times and cant find anything
- 12-28-2012, 09:01 PM #2
Member
- Join Date
- Dec 2012
- Location
- Des Moines, IA
- Posts
- 33
- Rep Power
- 0
Re: Simple error help
I think you have some other problems too, but your first issue is this line:
public class Scanner {
You named your class the same as the one your trying to import. Try giving it a different name.
- 12-28-2012, 09:18 PM #3
Member
- Join Date
- Dec 2012
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
Simple error I believe
By Jamison5213 in forum AndroidReplies: 1Last Post: 06-14-2012, 08:26 PM -
I need help with a simple error
By grim in forum New To JavaReplies: 2Last Post: 01-26-2012, 02:28 AM -
Simple Method Gives Me an Error
By grahamcrackeh in forum New To JavaReplies: 6Last Post: 06-10-2011, 04:00 PM -
30 line simple gui, simple error, need help
By cc11rocks in forum New To JavaReplies: 6Last Post: 02-05-2011, 08:33 PM -
Simple Error ???
By darkblue24 in forum New To JavaReplies: 3Last Post: 03-26-2010, 08:15 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks