-
Notifications
You must be signed in to change notification settings - Fork 0
2.3 Use the static and final keywords
Weverton edited this page Aug 30, 2016
·
1 revision
A classe é carregada quando é apresentada a sua primeira referência.
public class StaticTest {
static {
System.out.println("In static");
}
{
System.out.println("In non - static");
}
public static void main(String args[ ]){
StaticTest st1; //1
System.out.println(" 1 ");
st1 = new StaticTest(); //2
System.out.println(" 2 ");
StaticTest st2 = new StaticTest(); //3
}
}
Saída: In static, 1, In non - static, 2, In non - static