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 4 of 4

Thread: (Java)Scanner troubles(Eclipse)

  1. #1
    Junior Member
    Join Date
    Jan 2014
    Posts
    12
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Cool (Java)Scanner troubles(Eclipse)

    here is my code
    Scanner myScanner = new Scanner(System.in);
    		myScanner.nextLine();
    		System.out.println(myScanner.next());
    		myScanner.close();


    the problem is when i run it i type hello and nothing happens then if i type hello again it prints hello like it should i just wanted to know if this is normal or is it a bug?




    -ClarmonkGaming

  2. #2
    Member
    Join Date
    Feb 2014
    Posts
    180
    Thanks
    0
    Thanked 48 Times in 45 Posts

    Default Re: (Java)Scanner troubles(Eclipse)

    It is a bug in your code. See Java.util.Scanner.next() Method Example for a example, and Scanner (Java Platform SE 7 ) for a description of the nextLine() method.

  3. #3
    Junior Member
    Join Date
    Jan 2014
    Posts
    12
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: (Java)Scanner troubles(Eclipse)

    thx

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: (Java)Scanner troubles(Eclipse)

    Did you figure it out?

Similar Threads

  1. Eclipse Error: Scanner resource leak
    By NorrinGalan in forum Java IDEs
    Replies: 3
    Last Post: February 7th, 2014, 05:27 AM
  2. Java user input troubles using the scanner class
    By Lach in forum What's Wrong With My Code?
    Replies: 4
    Last Post: October 9th, 2013, 11:13 AM
  3. Replies: 2
    Last Post: September 25th, 2013, 03:35 PM
  4. Having troubles with Method Headers [Java Programming]! HELP!?
    By ERC117 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 13th, 2013, 09:42 AM