We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
this method tells about the token present in te buffer.
i.e it will return true if token is present and false if it is not.
for example, take a look at this
public class ScannerDemo {
public static void main(String[] args) {
String s = "Hello World! 3 + 3.0 = 6";
// create a new scanner with the specified String Object
Scanner scanner = new Scanner(s);
// check if the scanner has a token
System.out.println("" + scanner.hasNext());
// print the rest of the string
System.out.println("" + scanner.nextLine());
// check if the scanner has a token after printing the line
System.out.println("" + scanner.hasNext());
// close the scanner
scanner.close();
Java Loops I
You are viewing a single comment's thread. Return to all comments →
this method tells about the token present in te buffer. i.e it will return true if token is present and false if it is not. for example, take a look at this
public class ScannerDemo { public static void main(String[] args) {
} }
output of this program will be
true
Hello World! 3 + 3.0 = 6
false