Skip to main content

What is system.out.println();

This is output statement.We use print() or println() method to print the message or value of variables.

print() method is define under predefined class System (under PrintStream). print() method is called through out object which is also predefined.

we can create own output object which call print() method.

Example


PrintStream myprint = new PrintStream(System.out, true);
myprint.println("Hello World!");

How to find length of any word?

Please see the below example carefully to know about System.out.println() .If you able to understand the example then you understand System.out.println() eaisly.


     Class Test
       {
   Static String s=“java”;
       }
   
  1. As you know here Test is a class.
  2. “s” is a static variable type String.
  3. Here “java” is nothing but the value of “s”.
Now I am going to print the length(How many character) of “s”.
So i am writing.

Test.s.length();

Example

      Class System
        {
   Static PrintStrem out;
     .
     .
     .
 }
  
  1. As you know here System(present in java.lang package) is a class.
  2. “out” is a static variable type PrintStream.
  3. Here “java” is nothing but the value of “s”.

Comments