Could you explain the output for the program below? Is the output specifying a reference of the Scanner object in RAM (I don't see any hex hash) or something else?

Thank you!

    import java.util.Scanner;

        public class ScannerTest
            public static void main(String args[])
                Scanner input = new Scanner(System.in);

                System.out.println ("Scanner = " + input);


Scanner = 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]

Recommended Answers

All 3 Replies

The data from the scanner is binary. You are trying to output that as text. You need to decode the binary data first.

Your code invokes toString() method (when an object reference is used in string context) and it returns string representation of an object. Take a look at toString() - Oracle Tutorial.

Hello rubberman and avd - thanks a lot for the reply!

rubberman - how do I go about decoding the binary data?

Thank you!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.