Java Scanner tokens() MethodThe tokens() method of Java Scanner class is used to get a stream of delimiter-separated tokens from the Scanner object which are in using. This method might block waiting for more input. SyntaxFollowing is the declaration of tokens() method: ParameterThis method does not accept any parameter. ReturnsThe tokens() method returns a sequential stream of token strings. ExceptionsIllegalStateException- It will thrown this Exception if the innvocation is done after Scanner is closed. Compatibility VersionJava 1.9 and above Example 1Output: JavaTpoint Abhishek Male 22 Example 2Output: 1 2 red blue Next TopicJava-locale |
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