Results 1 to 6 of 6
  1. #1
    bigj is offline Member
    Join Date
    Dec 2009
    Posts
    68
    Rep Power
    0

    Default what is this output?

    Java Code:
    public class NewMain {
    
        public static void main(String[] args) {
    
            Scanner sc = new Scanner(System.in);
            
            System.out.println(sc);
        }
    }

    output
    Java Code:
    run:
    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]

    i used to encounter some memory address representation due to some mistyping..

    but what is this one... any answer would be appreciated ... just want to know what is this one....

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    You're displaying the results from the Scanner object's toString method call. For details on how this is defined, see the Scanner API: Scanner API

    For more details, check out Scanner's source code that you have in a zip file on your hard drive with your JDK.

  3. #3
    bigj is offline Member
    Join Date
    Dec 2009
    Posts
    68
    Rep Power
    0

    Default

    thank you sir...

  4. #4
    bigj is offline Member
    Join Date
    Dec 2009
    Posts
    68
    Rep Power
    0

    Default

    ahh so if this object not calling anything from its class
    it will simply return a string representation of an object, i even tried to
    use the toString() method, the ouput is still the same..

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Quote Originally Posted by bigj View Post
    ahh so if this object not calling anything from its class
    it will simply return a string representation of an object,
    I don't understand what you're saying here or what you're trying to do.

    i even tried to use the toString() method, the ouput is still the same..
    You rarely if ever want to call System.out.println on your Scanner object. I figured you were just doing this for experimental purposes, but I guess not.

    It's time for you to tell us just what you're trying to do, I think.

  6. #6
    bigj is offline Member
    Join Date
    Dec 2009
    Posts
    68
    Rep Power
    0

    Default

    I figured you were just doing this for experimental purposes,
    exactly sir... some future reference

    i just want to know what does those output means...
    anyway im satified with your response in my question....

Similar Threads

  1. Java, output string, getting correct output? HELP!
    By computerboyo in forum New To Java
    Replies: 2
    Last Post: 02-25-2009, 11:44 PM
  2. what the outPut
    By alksam in forum Advanced Java
    Replies: 5
    Last Post: 12-25-2008, 01:44 PM
  3. different output
    By pro85 in forum Java Applets
    Replies: 6
    Last Post: 08-05-2008, 01:42 PM
  4. Why the output is always zero
    By mehrotra.chitij in forum New To Java
    Replies: 12
    Last Post: 04-25-2008, 04:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •