Bear in mind that Java code runs in the JVM, and the JVM only communicates to the outside world in a few specified ways. So if you want to print to a console, you will need to call a method that somehow (after JNI, etc.) gets mapped to an IO operation on your actual OS. Unless you plan on building a new OS-level IO operation (in which case you can't write it in Java anyway), your best bet is to use an existing class that already knows how to talk to the outside world.
As it happens, the java.io.PrintStream class knows how to write to an OS level file stream, and the OS provides a file stream for the console (stdout). (Technically, PrintStream only knows how to write to an OutputStream, and OutputStream knows how to write to an OS level file stream, but I don't want to get bogged down in details.) Java provides an instance of PrintStream already attached to your process's standard output stream; that PrintStream object can be referenced as the out property of the java.lang.System object. Given that PrintStream has methods like println(), you can write:
java.lang.System.out.println("Hello, world!");
Since you always get java.lang.* imported by default, you can shorten that to:
System.out.println("Hello, world!");
Alternatively, you can assign the PrintStream instance to a local variable:
import java.io.PrintStream;
public class HelloWorld {
public static void main(String[] args) {
PrintStream p = System.out;
p.println("Hello, world!");
}
}
What does your "user defined method to print" do that the println() method of PrintStream objects doesn't? If you're interested in formatting the output, then you need to format it as a String before you call the println() method. As a convenience, you can wrap up the formatting and actual printing in a single helper method. Is this what you're actually looking for?