public class Insect {
public int i = 0;
public Insect(){
}
public void print(){
System.out.println("Insert");
}
public static void printStatic(){
System.out.println("static:Insert");
}
}
导出类
public class Beetle extends Insect{
public int i = 1;
public Beetle(){
}
public void print(){
System.out.println("Bettle");
}
public static void printStatic(){
System.out.println("static:Bettle");
}
}
main函数
public static void main(String[] args){
Insect insect = new Insect();
Insect beetle = new Beetle();
insect.printStatic();
beetle.printStatic();
System.out.println(insect.i);
System.out.println(beetle.i);
}