Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: User input error help.

  1. #1
    Junior Member
    Join Date
    Jun 2013
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question User input error help.

    Alright so basically today I decided I wanted to learn Java as it has been on my to do list for about 6 months now and basically I asked a few friends who knew how to program and they redirected me to thenewboston's tutorials on java programming. Everything was going smooth for awhile I was understanding everything he said and I was taking notes and such and then I got on to his user input tutorial. Now I listened to what he said, took notes on what he said what this and that did, and typed in what he wrote down. Now what happened whenever I ran it on Eclipse is that it gave me this error message.Exception in thread "main" java.lang.Error: Unresolved compilation problem: The method nextline() is undefined for the type Scanner at apples.main(apples.java:6)Could someone please help on what I should do. The code to what I'm trying to use to get user input is this....
    import java.util.Scanner;

    public class apples{
    public static void main(String args[]){
    Scanner bucky = new Scanner(System.in);
    System.out.println(bucky.nextline());
    }
    }


  2. #2
    Member
    Join Date
    May 2011
    Location
    west palm beach, FL
    Posts
    189
    My Mood
    Tired
    Thanks
    41
    Thanked 11 Times in 10 Posts

    Default Re: User input error help.

    your bucky.nextline

    should be

    bucky.nextLine

    notice the capitol L in line

    then when you run it type some word like hi in the console then it will return the word in the println

  3. The Following User Says Thank You to derekxec For This Useful Post:

    Puffy Fawter (June 16th, 2013)

  4. #3
    Junior Member
    Join Date
    Jun 2013
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: User input error help.

    Quote Originally Posted by derekxec View Post
    your bucky.nextline

    should be

    bucky.nextLine

    notice the capitol L in line

    then when you run it type some word like hi in the console then it will return the word in the println
    Thank you so much. Such a stupid mistake.

  5. #4
    Member
    Join Date
    May 2011
    Location
    west palm beach, FL
    Posts
    189
    My Mood
    Tired
    Thanks
    41
    Thanked 11 Times in 10 Posts

    Default Re: User input error help.

    part of learning

  6. #5
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    987
    Thanks
    6
    Thanked 206 Times in 182 Posts

    Default Re: User input error help.

    As an aside if you're like me you'll make lots of typos as you learn a new technology. "The method whatever() is undefined etc" is common indication by the compiler of a typo.

    The API documentation is very useful here. Click "Scanner" on the left and you will get the documentation for this class. From there you can check both the spelling and the number and types of arguments that the method takes. (The other common cause of this particular compiler message). It's never too soon to have the documentation open as you code, to get a better idea of what's happening and to round out the commentary in the videos.

  7. The Following User Says Thank You to pbrockway2 For This Useful Post:

    derekxec (June 16th, 2013)

Similar Threads

  1. [SOLVED] GUI user input error message
    By deeevo in forum What's Wrong With My Code?
    Replies: 2
    Last Post: May 24th, 2013, 02:00 AM
  2. User Input help
    By dx2731 in forum Java Theory & Questions
    Replies: 3
    Last Post: May 13th, 2013, 12:46 AM
  3. User Input help
    By lanmonster in forum What's Wrong With My Code?
    Replies: 20
    Last Post: January 20th, 2013, 10:44 AM
  4. Collecting user input error
    By SkyVar in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 19th, 2013, 09:48 PM
  5. Take user input
    By frabbi.cse in forum Java Theory & Questions
    Replies: 1
    Last Post: July 22nd, 2012, 12:48 PM