Java Scanner.toString()
Syntax
Scanner.toString() has the following syntax.
public String toString()
Example
In the following code shows how to use Scanner.toString() method.
// w ww . j a va2s . c om
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
String s = "java2s.com 1 + 1 = 2.0 true ";
Scanner scanner = new Scanner(s);
System.out.println(scanner.nextLine());
System.out.println(""+scanner.toString());
scanner.close();
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »