File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in System.out.print().

 
lokesh pattajoshi
Ranch Hand
Posts: 130
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
Every body i have some doubt in java's SOP statement.
Actually in System class we are creating static out object of PrintStream class and in our program we are calling as System.out.print().
my doubt is that without doing these thing directly we can call PrintStream.print() method what is the need of doing these things in System class.

Thanks in advance
 
Maneesh Godbole
Saloon Keeper
Posts: 10974
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even if you invoke PrintStream#print, you will still need to define where the output should go wont you? System.out does it for you.
From the API docs (emphasis added)
The "standard" output stream. This stream is already open and ready to accept output data. Typically this stream corresponds to display output or another output destination specified by the host environment or user.
 
lokesh pattajoshi
Ranch Hand
Posts: 130
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Maneesh,
Thank you very much for your replay actually i am beginner of java so can you please tell me exactly what is happening when we are calling System.out.print.

Regards,
Lokesh
 
Maneesh Godbole
Saloon Keeper
Posts: 10974
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider the statement System.out.print("Lokesh");

Here, "out" refers to a static variable which is pre-initialized to typically point to the console.
Thus, the data "Lokesh" is pumped via the output stream to the console.
 
lokesh pattajoshi
Ranch Hand
Posts: 130
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much Maneesh now i got it......
 
Maneesh Godbole
Saloon Keeper
Posts: 10974
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are welcome

PS. The Java API is well documented and quite descriptive. Also, in case you did not know, when you install the JDK, you also get the source code. Look for a file called src.zip under your JAVA_HOME (java installation directory). You can actually peek and the source code and see what is happening under the hood.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47293
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also a good idea to locate the Java™ Tutorials.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic