Java Scanner toString() MethodThe toString() method of Java Scanner class is used to get the string representation of Scanner using. The string representation of a Scanner contains information which is useful for debugging. SyntaxFollowing is the declaration of toString() method: ParameterThis method does not accept any parameter. ReturnsThe toString() method returns the string representation of this scanner. ExceptionsNA Compatibility VersionJava 1.5 and above Example 1Output: JavaTpoint 11 = 20.0 false java.util.Scanner[delimiters=\p{javaWhitespace}+][position=27][match valid=true][need input=false][source closed=true][skipped=false][group separator=\,][decimal separator=\.][positive prefix=][negative prefix=\Q-\E][positive suffix=][negative suffix=][NaN string=\QNaN\E][infinity string=\Q∞\E] Example 2Output: Input Desired Value: 2343270 String Value is: 2343270 Example 3Output: Result: [1, Result: 2, Result: 3] Next TopicJava-scanner-usedelimiter-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