can i build a user-defined class for printing anything using printstream variable just as "System" class ?
so what i did is:
import java.io.*;
public final class SystemDemo{
public final static InputStream give=null;//the same variables
public final static PrintStream take=null;
public final static PrintStream error = null;
}
and wanted to use this SystemDemo class as "System"(pre-defined) ,like
SystemDemo.take.println("something");
but i get a NullPointerException .
You can try this, will work same for your requirement,
public final class SystemDemo
{
public final static PrintStream take = new PrintStream(System.out);
}
And then use this as,
SystemDemo.take.println("Your String");
It worked fine, tested with Netbeans.