zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    web页面静态化与伪静态化
    mysql 优化之空间换时间
    QPS、PV、UV、RT 之间的关系
    接口
    MySQL 索引
    名词解释
    go 语言标识符
    Git版本控制与工作流
    Maven安装与配置
    IDEA工具使用说明
  • 原文地址:https://www.cnblogs.com/sxmcACM/p/3485096.html
Copyright © 2011-2022 走看看