父类
public class Uncle {
private String name;
private int age;
public Uncle(){
System.out.println("uncle构造方法");
}
public void fahongbao(){
System.out.println("舅舅发红包");
}
}
子类一:
public class UncleOne extends Uncle{
public UncleOne(){
super();
System.out.println("uncleone的构造方法");
}
public void chouyan(){
System.out.println("大舅喜欢抽烟");
}
public void fahongbao(){
System.out.println("大舅家道中落,发不起红包了,该送祝福了");
}
}
多层继承:
public class UncleUneSon extends UncleOne{
public UncleUneSon(){
System.out.println("UncleOneSon的构造方法");
}
public void fahongbao(){
System.out.println("大舅的儿子厉害了,接着发红包");
}
}
子类二:
public class UncleTwo extends Uncle{
public void hejiu(){
System.out.println("二舅喜欢喝酒");
}
//方法的重写 复写 覆写
public void fahongbao(){
System.out.println("二舅不仅发红包还送茅台");
}
}
public class Demo {
public static void main(String[] args) {
/* UncleOne uncleOne=new UncleOne();
uncleOne.fahongbao();
uncleOne.chouyan();
UncleTwo uncleTwo=new UncleTwo();
uncleTwo.fahongbao();
uncleTwo.hejiu();
UncleUneSon uncleUneSon=new UncleUneSon();
uncleUneSon.fahongbao();*/
UncleUneSon uncleUneSon= new UncleUneSon();
}
}
package edu.xcdq;
public class Demo01 {
public static void main(String[] args) {
final double PI=3.14;
//PI=6.25;
final int[]a=new int[]{1,2,3};
a[0]=10;
a[1]=20;
a[2]=30;
int []b=new int[3];
System.out.println(a[0]);
System.out.println(a[1]);
System.out.println(a[2]);
}
}