Tuesday, April 5, 2011

Can execute the java program without main method


We can execute a Java program without main() method by using the static block ...
ex.
   Class S
       {
         static int x,y,z;
        static
             {
        x=10;          y=20;
         z=x+y;
        System.out.print(z);
        System.exit(0);
               }
       }

Output:
     30


For Further Reading,

0 comments:

Post a Comment


 

Site Status

Man Behind Technical Today

Hello, I am Navin Bansal. I am a student of MCA in Rajsthan Institute of Engineering and Technology and owner of this blog. I share my view and ideas among people.