当前位置:网站首页>spuer和this关键字
spuer和this关键字
2022-07-19 14:53:00 【@@老胡】
简单来说,spuer就是父类的方法或者属性,this就是当前的类的方法或者属性
- 首先贴代码,这father和sun都有一个name属性,test里面会实例化sun的一个test方法
package javatest.supertest;
public class FatherTest {
protected String name="father";
public void print(){
System.out.println("This is father");
}
}
package javatest.supertest;
public class SunTest extends FatherTest {
private String name="sun";
public void print(){
System.out.println("This is sun");
}
public void test(String name){
System.out.println(name);//这里生成的是test传进来的形参
System.out.println(this.name);//这里生成的是SunTest中自带的name属性
System.out.println(super.name);//这里是生成了一个FatherTest的name属性
}
}
```java
package javatest.supertest;
public class Test {
public static void main(String[] args) {
SunTest sunTest=new SunTest();
sunTest.test("Test");
}
}
- 这里的输出就很明显了
边栏推荐
- 数据仓库dwb层,220620,hm,
- Introduction to incluxdb
- Formula editing==
- Swagger(或Postman)关于日期类型的传参方式
- SQL判断是否是今天 昨天 本月 上个月
- OPEN-SET RECOGNITION WITH GRADIENT-BASED REPRESENTATIONS
- Open-set recognition with gradient-based representations
- [JDBC] encapsulation of database addition, deletion, modification and query operations
- An example of shadow detection in image processing bdrar
- Upload pictures on wechat webpage
猜你喜欢
随机推荐
Examples of requests module usage
10. Thread
List集合排序(适用基本类型与对象类型)
review第1遍,220616,数据仓库DWD层,视频,
Acquisition and pretreatment of vibration signal
数据仓库dwb层,220620,hm,
Import changes and enable auto import of idea
数据仓库dwd层,DWB层建设实战、Presto计算引擎,preview_220616,
判断两个时间端是否含有交集
Download the picture according to the picture address to obtain the length and width size
谈谈 Ops(汇总 + 最终篇):工具和实践
Swagger (or postman) about the parameter transfer method of date type
Higherhrnet /pytorch-yolo4 environment deployment
xml文件更新操作 批量删除操作
Open-set recognition with gradient-based representations
DevOps失败了!
数仓ods,dwd层,220616,hm,
Force overwrite local code
分布式系統中數據存儲方案實踐
分布式系统中数据存储方案实践