Results 1 to 4 of 4
  1. #1
    suvojit168 is offline Member
    Join Date
    Jul 2009
    Posts
    10
    Rep Power
    0

    Default Question about System.in/out/err

    What are System.in/out/err and what is the purpose of declaring them as public and static inside the System class?

  2. #2
    dlorde is offline Senior Member
    Join Date
    Jun 2008
    Posts
    339
    Rep Power
    6

    Default

    For a description of what they are, read the System class JavaDocs. You can work out why they are declared public and static by finding out what the 'public' and 'static' qualifiers mean. You'll find this explained in the Java Tutorials, 'Declaring Member Variables' in the 'Classes and Objects' chapter. Unfortunately, this stupid forum software won't allow me to give you the link.

  3. #3
    suvojit168 is offline Member
    Join Date
    Jul 2009
    Posts
    10
    Rep Power
    0

    Question

    Quote Originally Posted by dlorde View Post
    You'll find this explained in the Java Tutorials, 'Declaring Member Variables' in the 'Classes and Objects' chapter.
    Thanks for your reply dlorde. But can you please tel me which book or source are you referring :confused:. I searched it in sun java tutorials but i cud not find any such reference there. Please help me in figuring out the useful source...

    Thanks
    SCY :)

  4. #4
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    6

    Default

    I think he means this:
    Java Platform SE 6
    Scroll down for 'System'

    But more to the point, I think you are asking what System.out/in/err are.

    All three are Streams. System.out is the output stream and by default its used to print to the console/terminal/command line
    For ex:
    Java Code:
    System.out.println("Hello, World!");
    System.in is also a stream, rather in input stream. It can be used for reading from a file or from the command line.
    For ex:
    Java Code:
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String txt = in.readLine();
    System.err is the same as System.out except its for printing error messages to the console with text coloring.

    I hope it helps :D
    Last edited by quad64bit; 07-26-2009 at 03:05 AM.

Similar Threads

  1. Question mark colon operator question
    By orchid in forum Advanced Java
    Replies: 9
    Last Post: 12-19-2010, 08:49 AM
  2. File System
    By Zosden in forum Advanced Java
    Replies: 3
    Last Post: 07-26-2008, 04:33 AM
  3. System Tray
    By JavaLerner in forum New To Java
    Replies: 2
    Last Post: 07-13-2008, 08:25 AM
  4. Getting System Properties
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-19-2007, 05:00 PM
  5. where is the system.property
    By osval in forum Advanced Java
    Replies: 2
    Last Post: 08-06-2007, 03:54 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
  •