r/javahelp • • Aug 30 '14

What does 'System.out...' mean in Java?

0 Upvotes

4 comments sorted by

17

u/Talon876 Extreme Brewer Aug 30 '14

System is a built in class with a static instance of a PrintStream object named out.

Because it's static, you can access it directly from the class, System.out.

The PrintStream object has methods such as print and println which allow you to output text to the console, as you've probably seen.

You could create your own 'System' class by doing something like this:

import java.io.PrintStream;

public class MySystem
{
    public static PrintStream printer = new PrintStream(System.out);
}

then you could write MySystem.printer.println("example"); and it would act the same way as System.out.println.

4

u/SikhGamer Aug 31 '14

You know, I've never bothered to look at how it worked. TIL, thanks.

3

u/Talon876 Extreme Brewer Aug 31 '14

There's a lot that can be learned from the javadocs. Glad I could help.

1

u/gndn Aug 30 '14

Did you read the docs? It's for writing to the standard output stream. It's mostly used for console based applications, and occasionally for logging purposes.