当前位置:网站首页>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() {
}
}
边栏推荐
- mysql乐观锁与悲观锁
- NFTs、Web3和元宇宙对数字营销意味着什么?
- UEFI learning 3.6 - ACPI table on ARM QEMU
- JSP getting started summary
- AI系统前沿动态第38期:谷歌已放弃TensorFlow?;训练大模型的四种GPU并行策略;LLVM之父:模块化设计决定AI前途
- swagger UI :%E2%80%8B
- MySQL optimistic lock and pessimistic lock
- 云原生数据库-Amazon RDS
- Jump game of leetcode topic analysis
- High performance computing center Infiniband overview
猜你喜欢
![[SUCTF 2019]CheckIn](/img/0e/75bb14e7a3e55ddc5126581a663bfb.png)
[SUCTF 2019]CheckIn
![[plugin:vite:import-analysis]Failed to resolve import “@/“ from ““.Does the file exist](/img/1f/dde52dc63de58d67f51161e318a9fb.png)
[plugin:vite:import-analysis]Failed to resolve import “@/“ from ““.Does the file exist

sql根据比较日期新建字段

开发者,你对云计算可能有些误解

Developer, you may have some misunderstandings about cloud computing

云原生数据库-Amazon RDS

Bioinformatics | effective drug target correlation prediction based on interacting neural network

I have been promoted. How can I get along with my former colleagues at the same level?

Gorm 高级查询

RT-Thread 添加 msh 命令
随机推荐
2021-04-12 链表第一次实现!!!
Lying trough, the most amazing paper artifact!
基于STM32设计的宠物投喂器
什么是BFC?BFC可以解决什么问题
多线程习题
Shengshihaotong enables high-quality development with industrial Digitalization
Neither rain nor sunshine
NIO例子
sql编写问题,求出当月和上月的环比值
Jog sport mode
#gStore-weekly | gStore源码解析(四):安全机制之黑白名单配置解析
Gstore weekly gstore source code analysis (IV): black and white list configuration analysis of security mechanism
Chain representation and implementation of linklist ---- linear structure
Mysql database introduction summary
Set the CPU to have 16 address lines and 8 data lines, and use mreq as the access control line number Connection between memory and CPU
同花顺推荐么?手机开户安全么?
Form repeated submission problem
[极客大挑战 2019]HardSQL
thymeleaf如何取url中请求参数值?
Sequential representation and implementation of sequencelist -- linear structure