March 16, 2010

Tired of typing “System.out.println()” every time you want to print to standard output?

Because “out” in “System.out” is a static PrintStream object, you can create a PrintStream variable, assign “System.out” to it, and reference that object from the new variable instead. Here’s the code:

import java.io.*;

public class TestPrint
{
private static PrintStream out = System.out;

public static void main(String args[])
{
out.println(“Hello, World!”);
out.println(“Testing, one, two, three”);
}
}

No comments:

Post a Comment

I'm certainly not an expert, but I'll try my hardest to explain what I do know and research what I don't know.

My Favorite Site's List

#update below script more than 500 posts