System.out.println() in Java
In java dialect print() and println() are the predefined non-static strategy for printStream class used to show esteem or message either in the same line or line by line separately. PrintStream class is having altered item reference in the System class (existing as a static properties) so that either print() or println() technique can be called with taking after sentence structure..
Syntax
System.out.print("--------------");
System.out.println("------------");
System.out.println("------------");
/* "out" is Object reference of printStream class
existing in system class as a static property. */
existing in system class as a static property. */
Example
class PrintStream { println() //-----------> non-static { ........ } print() //-----------> non-static { ........ ........ } } class System { Static PrintStream out; Static PrintStream err; }
Examples of SOP Statements
Example
System.out.println("Hello"); // ---------> Hello int x=10, y=20; System.out.println("x"); // ---------> x System.out.println(x); // ---------> 10 System.out.println("Hello"+x); // ---------> Hello10 System.out.println(x+y); // ---------> 30 System.out.println(x+y+"Hello"); // ---------> 1020Hello
Example
class Hello { public static void main(String arg[]) { System.out.println("Hello word"); } }
Output
Hello Word