package com.itheima.abstract1; public class Test { public static void main(String[] args) { } } abstract class A{ public String a; private static String b; public static int aa; public A(String a) { this.a = a; } public A() { } public String getA() { return a; } public void setA(String a) { this.a = a; } public static String getB() { return b; } public static void setB(String b) { A.b = b; } public static int getAa() { return aa; } public static void setAa(int aa) { A.aa = aa; } //抽象方法用abstrat修饰,只有方法签名,一定不能有方法体 public abstract void run(); } //一个类继承抽象类,必须重写完抽象类的全部抽象方法,否则这个类也必须定义成抽象类 class B extends A{ @Override public void run() { } }
使用抽象类的好处:
标签:aa,JAVA,String,void,static,面向,抽象类,public From: https://www.cnblogs.com/pengsuoqun123/p/18091615