wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes println Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "println" Watch "println" New topic
Author

println

agrah upadhyay
Ranch Hand

Joined: Sep 01, 2005
Posts: 579
System.out returns a PrintStream object and we call println() on it.But println() is defined in java.io.* .So how can we call it without importing
java.io package?
Akshay Kiran
Ranch Hand

Joined: Aug 18, 2005
Posts: 220
Ahem
PrintStream also has a println method.


"It's not enough that we do our best; sometimes we have to do<br />what's required."<br /> <br />-- Sir Winston Churchill
agrah upadhyay
Ranch Hand

Joined: Sep 01, 2005
Posts: 579
But to use that method, should not we import the package?
Kris Krason
Greenhorn

Joined: Aug 05, 2005
Posts: 25
Maybe it has a return statemant with a fully qualified class name ?

But probably, if we have :

import java.io.PrintStream;

public class System {
PrintStream out;
...
}

Than, compiler knows where to get that PrintStream class from, and code that uses System, doesn't have to import it anymore.


Kris Krason<br />SCJP1.4 (96%)<br />SCJP1.5 (91%)<br /> <br />See my <a href="http://krisreviews.com/2006/12/code-complete-second-edition/" target="_blank" rel="nofollow">Code Complete review</a><br /> <br /><a href="http://www.coderookie.com/2006/tutorial/the-pseudocode-programming-process/" target="_blank" rel="nofollow">Pseudocode Programming Process</a>
agrah upadhyay
Ranch Hand

Joined: Sep 01, 2005
Posts: 579
Thanx you very much Krason But
Maybe it has a return statemant with a fully qualified class name ?
What does it mean?
Kris Krason
Greenhorn

Joined: Aug 05, 2005
Posts: 25
PrintStream is in java.io.*

So to use it you should either hava an import java.io.* (or java.io.PrintStream), or just use java.io.PrintStream everywhere in your file.
Fully qualified name is the java.io.PrintStream.
[ October 12, 2005: Message edited by: Krzysztof Krason ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: println