STATIC, MAIN method

xiaoxiao2021-03-06  70

Public class test2 extends test1 {{system.out.print ("1");} TEST2 () {system.out.print ("2");} static {system.out.print ("3");} { System.out.print ("4");} public static void main (string [] args) {TEST1.MAIN (ARGS); new test2 ();}}

Class test1 {INT i = 10; {system.out.print ("7");}

TEST1 () {system.out.print ("5");

Static {system.out.print ("6");} public static void main (String [] args) {new test2 ();}} The above program is a MAIN method for the test is the Java interpreter default, when executed When a class, Java first executes its Static method, and then goes to whether there is a main method, execute the main method. INT i = 10; {INT i = 10;} These two are declared member variables, when loading a class, the member variables within the Class of the Class are initialized a STATIC method is an area under the membership of the class. There is your own memory separate memory address.

转载请注明原文地址:https://www.9cbs.com/read-91581.html

New Post(0)