My computer science teacher encountered this strange string while working with another student one day after class. The assignment was using Scanner and stepping through a string by delimiter.
java.util.Scanner[delimiters=\p{javaWhitespace}+][position=0][match valid=false][need input=false][ source closed = false ][skipped=false][group separator=\,][decimal separator=\.][positive prefix=][negative prefix=\Q-\E][positive suffix=][negative suffix=][NaN string=\Q?\E][infinity string=\Q∞\E]
Doesn’t that looks like a scary mess? Actually, it’s not so bad, it’s not even an error!
The Scanner class in Java has a toString method which allows it to be printed. The (so-called) documentation for the toString method states:
Returns the string representation of this Scanner. The string representation of a Scanner contains information that may be useful for debugging. The exact format is unspecified.
So when you use a Scanner and then subsequently print it out, it will spit out a representation of that Scanner at the that time, because on each step through a string, the Scanner changes slightly, based on weather certain things are true.
import java.util.*;
public class QuickTest {
public static void main(String[] args) {
Scanner scanner = new Scanner("Four score and seven years ago our fathers brought forth on this continent, " +
"a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.");
System.out.println(scanner);
// returns the following
/*
* java.util.Scanner[delimiters=\p{javaWhitespace}+][position=0][match valid=false][need input=false]
* [source closed=false][skipped=false][group separator=\,][decimal separator=\.]
* [positive prefix=][negative prefix=\Q-\E][positive suffix=][negative suffix=][NaN string=\Q?\E][infinity string=\Q∞\E]
* */
}
}
That’s all there is too this kind of message in Java, nothing too major, just silly.