Package Hello3;
public class Testcode {
private String name;
Public Testcode () {
System.out.println ("Construction method executed");
}
Building code Blocks
{
SYSTEM.OUT.PRINTLN ("Construction code block executed");
}
Static code blocks, which are executed directly when loading Testcode.class, are executed first, but only once when the two objects are loaded, and the class is executed once.
static{
System.out.println ("Static code block executed");
}
public void Jubu () {
Local code block
{
SYSTEM.OUT.PRINTLN ("Partial code block executed");
}
}
public static void Main (string[] args) {
System.out.println ("Hello");
Testcode tc1=new Testcode ();
Tc1.jubu ();
Testcode tc2=new Testcode ();
}
}
Operation result;
The static code block executes the
Hello
The construction code block executes the
The construction method executes the
The local code block executes the
The construction code block executes the
The construction method executes the
Java Learning code block