• java中的抽象类(abstract)


    具体看代码

     1 abstract class student {// 抽象方法放在类中,不能有new创建对象,没意义,必须让子类复写方法,复写后仍未抽象类
     2     abstract void study();// 由void study(){}改的
     3     // 抽象方法一定有抽象类,必须有关键字修饰
     4     // abstract void
     5     // study1();//如果有这个,子类必须复写其方法,如果不复写,在子类前必须加abstract,且必须将此方法放在子类中,前要加abstract
     6 }
     7 
     8 class BaseStudent extends student {
     9     void study() {
    10         System.out.println("base studing");
    11     }
    12 
    13 }
    14 
    15 class AdvStudent extends student {
    16     void study() {
    17         System.out.println("adv studing");
    18     }
    19 }
    20 
    21 public class TestAbstract {
    22 
    23     public static void main(String[] args) {
    24         new BaseStudent().study();
    25     }
    26 
    27 }
    View Code
  • 相关阅读:
    poj2240
    poj1135
    poj1062
    poj3278
    2218 补丁vs错误
    必做: 1041、1024、1077、2218、1183(较难)
    poj2828
    poj3253
    洛谷P1122 最大子树和
    1074 食物链
  • 原文地址:https://www.cnblogs.com/sxmcACM/p/3485096.html
Copyright © 2020-2023  润新知