Javatpoint Logo
Javatpoint Logo

Java Scanner hasNextLine() Method

The hasNextLine() is a method of Java Scanner class which is used to check if there is another line in the input of this scanner. It returns true if it finds another line, otherwise returns false.

Syntax

Following is the declaration of hasNextLine() method:

Parameter

This method does not accept any parameter.

Returns

The hasNextLine() method returns true if and only if this scanner has another line of input.

Exceptions

IllegalStateException

Compatibility Version

Java 1.5 and above

Example 1

Output:

Facebook.com 
true
 1 + 1 = 2.0 
true
 JavaTpoint.com 
false

Example 2

Output:

3
RV3280
RV2888C
2
RV3280
RV2502C
3
RV3280
RV1263
3
RV2363
RV3280

Example 3

Output:

hasNextLine
public
boolean
hasNextLine()

Next TopicJava Scanner Class



Help Others, Please Share

facebook twitter pinterest