当前位置:网站首页>2021-05-11抽象类
2021-05-11抽象类
2022-06-23 09:54:00 【鹿其其鹿】
抽象类
abstract修饰符可以用来修饰方法也可以修饰类,如果修饰方法,那么方法就是抽象方法,如果修饰类那就是抽象类
抽象类中可以没有抽象方法,但是有抽象方法的类一定要声明为抽象类
抽象类不能使用new关键字来创建对象,它是用来让子类继承的
抽象方法,只有方法的声明,没有方法的实现,它是用来让子类实现的
子类继承抽象类,那么就必须要实现抽象了类没有实现的抽象方法,否则该子类也要声明为抽象类
package oop.demo10;
//abstract抽象类
public abstract class Action {
//约束-有人帮我们实现
//abstract,抽象方法,只有方法名字,没有方法的实现
public abstract void doSomething();
//不能new这个抽象类,只能靠子类去实现它:约束
//抽象类中可以写普通的方法
//抽象方法必须在抽象类中
//抽象的抽象
//抽象的意义就是方便代码的使用
}
package oop.demo10;
//抽象类的所有方法,继承了它的子类,都必须实现它的方法
public class A extends Action {
@Override
public void doSomething() {
}
}
边栏推荐
- STM32F1与STM32CubeIDE编程实例-红外寻迹传感器驱动
- Go语言JSON 处理
- Bioinformatics | effective drug target correlation prediction based on interacting neural network
- web--信息泄漏
- [geek challenge 2019] hardsql
- sql根据比较日期新建字段
- Difference between global shutter and roller shutter
- Web -- Information Disclosure
- On shore experience of Chang'an University majoring in transportation in 2023
- regular expression
猜你喜欢

分布式锁的三种实现方式
![[MRCTF2020]Ez_bypass](/img/cd/bd6fe5dfc3f1942a9959a9dab9e7e0.png)
[MRCTF2020]Ez_bypass

Is there anyone who plans to open source an industrial "seckill" system architecture?

UEFI source code learning 3.7 - norflashdxe

Dr. Sun Jian was commemorated at the CVPR conference. The best student thesis was awarded to Tongji Ali. Lifeifei won the huangxutao Memorial Award

Successful experience of postgraduate entrance examination in materials and Chemical Engineering (metal) of Beijing University of Aeronautics and Astronautics in 2023

web--信息泄漏

RT thread add MSH command

Shengshihaotong enables high-quality development with industrial Digitalization

什么是BFC?BFC可以解决什么问题
随机推荐
[SUCTF 2019]CheckIn
正则表达式
RGB and CMYK color modes
Game of life of leetcode topic analysis
[SUCTF 2019]CheckIn
I have been promoted. How can I get along with my former colleagues at the same level?
Is there anyone who plans to open source an industrial "seckill" system architecture?
文件IO(1)
Go unit test
Cloud native database Amazon RDS
Servlet-02 lifecycle
Go 字符串比较
Gesture recognition based on mediapipe
After the uncommitted transactions in the redo log buffer of MySQL InnoDB are persisted to the redo log, what happens if the transaction rollback occurs? How does the redo log handle this transaction
Centre de calcul haute performance - nvme / nvme - of - nvme - of overview
[極客大挑戰 2019]HardSQL
xml相关面试题
mysql中innodb下的redo log什么时候开始执行check point落盘的?
[wangdingbei 2020 Qinglong formation]areuserialz
Web -- Information Disclosure