aspose file tools*
The moose likes Beginning Java and the fly likes about System.out Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "about System.out" Watch "about System.out" New topic
Author

about System.out

Santhi Bharath
Ranch Hand

Joined: Jun 03, 2008
Posts: 75
System.out.println();

in the above statement my friend saying that,

System is a class
out is a object
println() is a method of System.

and my idea is

System.out is an object.

but,the thing bemusing us is

why we are using class name(System) in object(System.out) name?
why we are using different notation for creating an object name (System.out)?
is it any special convention?

please let me clear.


thanks and regards<br />Santhi Bharath<br />SCJP 5.0, SCWCD 5.0
Eric Weinberg
Greenhorn

Joined: Nov 11, 2004
Posts: 18
When in doubt check the API.

System is a class.
out is a static member that is a PrintStream
println() is a method found in PrintStream
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19692
    
  20

Originally posted by Santhi Bharath:
why we are using different notation for creating an object name (System.out)?

You're not creating an object - you're getting the already created object that is stored in the static System.out field.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Santhi Bharath
Ranch Hand

Joined: Jun 03, 2008
Posts: 75
thank you for your quick reply and if my question seems silly i regret it.

why we are using System class to access PrintStream variable and method?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41792
    
  62
You're using System because that's where the "out" field is defined that can be used to print something to Standard Output (i.e., the console or system log).

If you want to print elsewhere using a PrintStream, you'd use the classes in the java.io. package to construct a new one.


Ping & DNS - my free Android networking tools app
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38726
    
  23
Originally posted by Santhi Bharath:
thank you for your quick reply and if my question seems silly i regret it.
It's not a silly question at all. It takes a long time to work out what System.out is if you don't know.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: about System.out