define System.out.println()?

In the System.out.println()
          -System is a class that is define in the java.lang package which is by default imported in our program.
         -out, is the object of PrintStream class and it is declared as static in the System class.
         -println(), is the function of PrintStream class.

     Code to demonstrate how the "out" object associate with System class:-

class System1
{
             static PrintStream1 out;
             //starting of static block
             static                                             
             {
                      out=new PrintSream1();
             }
}

class PrintStream1
{
         public void printline()
         {
                     //code of the printline() by java developers........
         } 
}

class <userdefine>
{
        public static void main(String[] args)
        {
                  System1.out1.printline();
        }
}

This is called class level association, we associate the object of one class with the other class.
and static block will load the code with in it when class is loaded.

please go through this video for detailing of above topic
https://youtu.be/VUB-xF_N608

Comments

Popular posts from this blog

Inter-Thread communication

Reflection in java