Results 1 to 3 of 3
  1. #1
    Wisty is offline Member
    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0

    Default 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

  2. #2
    foulkelore is offline Member
    Join Date
    Dec 2012
    Location
    Des Moines, IA
    Posts
    35
    Rep Power
    0

    Default 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.

  3. #3
    Wisty is offline Member
    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0

    Default Re: Simple error help

    thanks. i changed the class name and the rest pretty much solved itself from there. i will be more careful with what i name my class files now.

Similar Threads

  1. Simple error I believe
    By Jamison5213 in forum Android
    Replies: 1
    Last Post: 06-14-2012, 08:26 PM
  2. I need help with a simple error
    By grim in forum New To Java
    Replies: 2
    Last Post: 01-26-2012, 02:28 AM
  3. Simple Method Gives Me an Error
    By grahamcrackeh in forum New To Java
    Replies: 6
    Last Post: 06-10-2011, 04:00 PM
  4. 30 line simple gui, simple error, need help
    By cc11rocks in forum New To Java
    Replies: 6
    Last Post: 02-05-2011, 08:33 PM
  5. Simple Error ???
    By darkblue24 in forum New To Java
    Replies: 3
    Last Post: 03-26-2010, 08:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •