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

println

 
agrah upadhyay
Ranch Hand
Posts: 579
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahem
PrintStream also has a println method.
 
agrah upadhyay
Ranch Hand
Posts: 579
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But to use that method, should not we import the package?
 
Kris Krason
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
agrah upadhyay
Ranch Hand
Posts: 579
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic