当前位置:网站首页>2021-05-07 package inheritance super this
2021-05-07 package inheritance super this
2022-06-23 10:07:00 【Deer like deer】
encapsulation
High cohesion Low coupling
Property private get/set
The significance of encapsulation :
Improve the security of the program , Protection data
Hide the implementation details of the code
Unified interface
System maintainability increases
Inherit
The essence of inheritance is to abstract a batch of classes , In order to achieve better modeling of the real world
extends It means to extend , A subclass is an extension of a parent
java Class has only singleton inheritance , No more inheritance
Subclass inherits parent , Use keywords extends To express
//Person people Parent class
public class Person {
public void say(){
System.out.println(" Said a word ");
}
}
package oop.demo5;
// Student is people Subclass
public class Student extends Person{
}
public class Application {
public static void main(String[]args){
Student student = new Student();
student.say();
}
}
Private things cannot be inherited ( Unless with get,set extract )
super Be careful
- super Call the constructor of the parent class , Must be in the first... Of the construction method
- super Must only appear in a subclass's method or constructor
- super and this Cannot call constructor at the same time
super VS this
Different objects represented :
this: Calling the object itself
super: Represents the application of the parent object
Premise :
this: You can use without inheritance
super: It can only be used under the condition of inheritance
Construction method :
this(): Call the constructor of this class
super(): Call the construction of the parent class
.
边栏推荐
- Go语言JSON 处理
- mysql中innodb下的redo log什么时候开始执行check point落盘的?
- 2021-04-16数组
- Navagation navigation
- 2022 gdevops global agile operation and maintenance summit - essence playback of Guangzhou station (with PPT download)
- laravel8 beanstalk 使用说明
- Mysql database introduction summary
- Unity技术手册 - 生命周期内速度限制(Limit Velocity Over Lifetime)子模块和速度继承(Inherit Velocity)子模块
- Game of life of leetcode topic analysis
- On shore experience of Chang'an University majoring in transportation in 2023
猜你喜欢

Mysql database introduction summary

构建信创产业生态,移动云立足全栈自主创新连放大招

2022 Gdevops全球敏捷运维峰会-广州站精华回放(附ppt下载)

CVPR大会现场纪念孙剑博士,最佳学生论文授予同济阿里,李飞飞获黄煦涛纪念奖...

oracle中遇到的bug

云原生数据库-Amazon RDS

2021-05-07构造器

SQL writing problem to calculate the ring ratio of the current month and the previous month

sql根据比较日期新建字段

Pet Feeder Based on stm32
随机推荐
SQL教程之SQL 中数据透视表的不同方法
JS教程之 什么是 JSX?为什么我们需要它?
有没有人,计划开源一套工业级“秒杀”系统架构?
Comic | code review is driving me crazy!
Successful experience in postgraduate entrance examination for MTI master of English translation major of Beijing University of science and technology in 2023
After installing these five plug-ins, pycharm can be used for takeoff!
2021-04-15
安装typescript环境并开启VSCode自动监视编译ts文件为js文件
Unable to enter the system normally, press F8 to select other items to try to enter
Bugs encountered in Oracle
RPC kernel details you must know (worth collecting)!!!
启明星辰华典大数据量子安全创新实验室揭牌,发布两款黑科技产品
开发者,你对云计算可能有些误解
数值计算方法
Lying trough, the most amazing paper artifact!
AI system frontier dynamics issue 38: Google has abandoned tensorflow?; Four GPU parallel strategies for training large models; Father of llvm: modular design determines AI future
Bi SQL drop & alter
2021-04-27类和对象
Is there anyone who plans to open source an industrial "seckill" system architecture?
炫酷相册代码,祝对象生日快乐!