what is system.out.println in java?
System.out.println is a Java statement that prints the argument passed into the console which is generally standard output.
- The System is the name of the class in java.lang package.
- out is an object of print stream class and declared as static in System class. Present in java.lang package.
- println() is a method of the PrintStream class. Present in java.io package.
Explaning System.out.println using Java Programs:
Class A Program:
System.out.println(“FunA() of A”);
Class Sdemo program:
static int i = 1;
static A a1 = new A();
Class Test program:
public static void main(String args)
In the above program look at the Sdemo.a1.funA();
- Sdemo is the name of the class.
- a1 is the object of Class A which is declared as static in Sdemo class.
- funA() is a method of A class. Like Sdemo.a1.funA(); System.out.println() is also declared.
Also, read: Java Collections interview questions