Java Scanner nextLine() MethodThe nextLine() method of Java Scanner class is used to get the input string that was skipped of the Scanner object. SyntaxFollowing is the declaration of nextLine() method: ParameterThis method does not accept any parameter. ReturnsThe nextLine() method returns the the line that was skipped. ExceptionsNoSuchElementException- It will thrown this Exception if no line was found. IllegalStateException- It will thrown this Exception if the innvocation is done after Scanner is closed. Compatibility VersionJava 1.5 and above Example 1Output: Enter Item ID: A151 Enter Item price: 3473.75 Price of Item A151 is $3473.75 Example 2Output: hasNextLine public boolean hasNextLine() IllegalStateException Example 3Output: Facebook.com true 1 + 1 = 2.0 true JavaTpoint.com false Next TopicJava-scanner-nextlong-method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India