1 package com.dengbao;
2
3 public abstract class A {
4 private String name;
5 public A(String name) {
6 this.name=name;
7 }
8 public void A(String name2) {
9 }
10 public String getName() {
11 return this.name;
12 }
13 public abstract void fun();
14 }
package com.dengbao;
public class B extends A {
//抽象类不能实例化
public B(String name) {
super(name);
}
public void fun() {
System.out.println(super.getName());
}
}
1 package com.dengbao;
2
3 public class DemoAB {
4
5 public static void main(String[] args) {
6 B b =new B("悟空");
7 b.fun();
8 }
9 }
This moment will nap, you will have a dream; but this moment study, you will interpret a dream.