Computer Applications
Distinguish between the following:
hasNext() and hasNextLine()
Input in Java
22 Likes
Answer
hasNext() | hasNextLine() |
---|---|
Returns true if the Scanner object has another token in its input. | Returns true if there is another line in the input of the Scanner object. |
Answered By
14 Likes
Related Questions
Distinguish between the following:
next() and next().charAt(0)
Consider the following input:
one, two three, four, fiveWhat values will the following code assign to the variables input1 and input2?
String input1 = keyboard.next();
String input2 = keyboard.next();Distinguish between the following:
next() and hasNext()
Write a line of code that:
i. Creates a Scanner object named scanner to be used for taking keyboard input.
ii. Uses the object scanner to read a word from the keyboard and store it in the String variable named stg.