class A{
public static int value = 134;
static{
System.out.println("A");
}
}
class B extends A{
static{
System.out.println("B");
}
}
public class Demo {
public static void main(String args[]){
int s = B.value;
System.out.println(s);
}
}
複製代碼
A
B
134
複製代碼
A
134
複製代碼
class A{
public static int valueA = 134;
static{
System.out.println("A");
}
}
class B extends A{
public static int valueB = 245;
static{
System.out.println("B");
}
}
public class Demo {
public static void main(String args[]){
int s = B.valueB;
System.out.println(s);
}
}
複製代碼
A
B
245
複製代碼
public static int value1 = 5;
public static int value2 = 6;
static{
value2 = 66;
}
複製代碼