System.out.println

System class has hasA realationship with PrintStream class so System class access the object of PrintStream class i.e to out object.
like :

class System
{
PrintStream out;
}

class PrintStream
{
println()
{
}
}

    System class  Variables

  1. err::=Standard Error Reporting Stream::PrintStream. [ PrintStream ]
  2. out::=Standard Output stream:: PrintStream. [ PrintStream ]
  3. in::=Standard Input stream::InputStream

System class  Methods



  1. arraycopy(Object, int, Object, int, int)::= Copies an array from the source array, beginning at the specified position, to the specified position of the destination array.
  2. exit(int)::= Exits the virtual machine with an exit code. [ Array Copy ]
  3. currentTimeMillis()::= Returns the current time in milliseconds GMT since the epoch (00:00:00 UTC, January 1, 1970). See Also [ Date ]
  4. gc()::= Runs the garbage collector.
  5. getProperties()::= Gets the System properties.
  6. getProperty(String)::= Gets the System property indicated by the specified key.
  7. getProperty(String, String)::= Gets the System property indicated by the specified key and def.
  8. getSecurityManager()::= Gets the system security interface.
  9. load(String)::= Loads a dynamic library, given a complete path name.
  10. loadLibrary(String)::= Loads a dynamic library with the specified library name.
  11. runFinalization()::= Runs the finalization methods of any objects pending finalization.
  12. setProperties(Properties)::= Sets the System properties to the specified properties.
  13. setSecurityManager(SecurityManager)::= Sets the System security


for getting full detail see the whole  package 




With out main

public class Demo{
    static
    {
        System.out.println("hello");
        System.exit(0);
   }
    }
}

Since we know that all static block executes first at the time of class loading in class loader so this program prints hello before going to main .
this program will executes in the java versions which had coming before java 1.7
But this will doesn't work with java 1.7 since in java 1.7 concept change ..
in java 1.7  control goes first to main then executes all static blocks.

Counters