• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Overloading System.out.println();

 
Prasath Manohar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to overload an object,can I overload System.out ?
 
Ashutosh Limaye
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the System class in docs....see what an out object is...
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64717
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prasath Manoha, please take more care in chosing which forum in which to post your questions. This forum is for JDBC questions.

I've moved this post to Java in General (beginner).
 
Kj Reddy
Ranch Hand
Posts: 1704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Prasath Manohar:
Is it possible to overload an object,can I overload System.out ?


Overloading an object? How do you that?

I see some people assigning System.out object to some referene and call println method on that reference.

for example:

java.io.PrintStream ps = System.out;
ps.println("Hello world");
 
Manesh Kumar
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Prasath Manohar:
Is it possible to overload an object,can I overload System.out ?


I think you are expecting to use different stream to print rather than the console.

If thats is the case,

You can use System.setOut(PrintStream);

Example
For printing all the System.out.println() to a file.

System.setOut(new PrintStream(new FileOutputStream("console.log")));

Of course, this will no more print to the console for all System.out.println().
[ March 22, 2006: Message edited by: Dilip Kumar Jain ]
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that the above has nothing to do with overloading at all.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic