Results 1 to 4 of 4
  1. #1
    javanew is offline Member
    Join Date
    Mar 2010
    Posts
    49
    Rep Power
    0

    Default please help me with this Q?

    Suppose you enter 34.3, the ENTER key, 57.8, the ENTER key, 789, the ENTER key. Analyze the following code.
    Scanner scanner = new Scanner(System.in);
    int value = scanner.nextDouble();
    int doubleValue = scanner.nextInt();
    String line = scanner.nextLine();

    the answer is :
    After the last statement is executed, line contains character '\n '



    why ?????? please explain me with details,,, i really appreciate your help!:confused:

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Duplicate post deleted.

    Please do not multipost the same question in multiple fora. Also, please feel free to demonstrate some effort at any time.

  3. #3
    curmudgeon is offline Senior Member
    Join Date
    May 2010
    Posts
    436
    Rep Power
    5

    Default

    What is this, ask other people to do my homework for me day?

  4. #4
    curmudgeon is offline Senior Member
    Join Date
    May 2010
    Posts
    436
    Rep Power
    5

    Default

    Java Code:
    ....
    int value = scanner.nextDouble();  // ????? swapped ????
    int doubleValue = scanner.nextInt();  // ????? swapped ????

Posting Permissions

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