File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

about System.out

 
Santhi Bharath
Ranch Hand
Posts: 75
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Eric Weinberg
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20396
47
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Santhi Bharath
Ranch Hand
Posts: 75
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47300
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic