Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

System.out.println( );

 
Larry Lai
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,
This question may be too simple but I really want to know because a lot of books would be read that the first topic (getting start) as follows:
System.out.println("Hello Javaranch!!! How're you ?");
What's that ?
I mean System.out.println("Hello Javaranch!!! How're you?");
// objectname.methodname();
Is it correct?

Thanks
Larry
 
Rodney Woodruff
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The System class is included by default in all your executing programs as it is apart of java.lang package.
The System class contains several class fields such as out, in and err which allow various types of output and input operations such as the overloaded println() method.
Check here System Class and then post more questions if you have any.
[ May 23, 2002: Message edited by: Rodney Woodruff ]
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System is a class.
out is a static PrintStream object of System.
println is a method of PrintStream.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could do something like this if you wanted:
PrintStream p = System.out;
p.println("hello");
 
Manish Hatwalne
Ranch Hand
Posts: 2591
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
More accurately in, out and err are static members of the System class, where err and out are objects of type PrintStream, and in is an InputStream object. Hence it is essentially objName.methodName(), where objects are static members of System class, so you do not need an instance of System class to access them.
HTH,
- Manish
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic