package day09;//加上abstract 变成抽象类publicabstractclassFulei{int num =1;publicvoidmethod(){
System.out.println("调用了父类方法method。");}publicvoidmethod1(){int a =100;
System.out.println("覆盖重写失败");}publicFulei(int num){
System.out.println("父类构造方法。");}publicabstractvoidchouxiangfangfa();}
package day09;publicclassZileiextendsFulei{int num =3;publicvoidmethod(){int num =33;
System.out.println("调用了子类方法method。");
System.out.println(num);//局部
System.out.println(this.num);//子类
System.out.println(super.num);//父类}@Override//检查publicvoidmethod1(){int b =66;
System.out.println("覆盖重写成功"+ b);}publicZilei(){super(10);//通过super调用父类重载构造
System.out.println("子类构造方法。");}@Override//检查publicvoidchouxiangfangfa(){};//继承抽象父类,覆盖重写}
package day0902;//发红包,平均分配import java.util.ArrayList;import java.util.Scanner;publicclassD0902{publicstaticvoidmain(String[] args){
Fa one =newFa("群主",100);
Shou two =newShou("成员1",0);
Shou three =newShou("成员2",0);
Shou four =newShou("成员3",0);
one.show();
two.show();
three.show();
four.show();
Scanner sc =newScanner(System.in);
System.out.print("群主输入红包金额:");int famoney = sc.nextInt();
System.out.print("群主输入红包个数:");int fenshu = sc.nextInt();
ArrayList<Integer> list = one.fa(famoney,fenshu);
two.shou(list);
three.shou(list);
four.shou(list);
one.show();
two.show();
three.show();
four.show();}}
菜鸡学习day09package day09;/*继承性(共性抽取)继承是多态的前提子类会继承父类的变量和方法父类public class 父类名称{}子类public class 子类名称 extends 父类名称{}若成员变量重名,则创建子类对象时,有两种访问方式:1.直接通过子类对象访问成员变量 等号左边是谁就优先用谁,向上最近2.间接通过成员方法访问...