博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
java this
阅读量:5288 次
发布时间:2019-06-14

本文共 1134 字,大约阅读时间需要 3 分钟。

this 代表什么

this 应用场景

When used as a primary expression, the keyword this denotes a value that is a reference to the object for which the instance method or default method was invoked , or to the object being constructed.

The value denoted by this in a lambda body is the same as the value denoted by this in the surrounding context.

 

Within an instance method or a constructor, this is a reference to the current object — the object whose method or constructor is being called.

You can refer to any member of the current object from within an instance method or a constructor by using this.

你可以在实例方法或构造器中通过使用this来指明当前对象的任意成员。

语法:

He did not refer to the report from Australia.

注意点:

this 是对象的引用

The most common reason for using the this keyword is because a field is shadowed by a method or constructor parameter.

 

The keyword this may be used only in the following contexts:

  •  in the body of an instance method or default method

  •  in the body of a constructor of a class 

  •  in an instance initializer of a class

  •  in the initializer of an instance variable of a class

  •  to denote a receiver parameter

 

转载于:https://www.cnblogs.com/zno2/p/5611296.html

你可能感兴趣的文章
xampp 提示 This setting can be configured in the file "httpd-xampp.conf".
查看>>
常见软件版本号
查看>>
struts2框架之类型转换(参考第二天学习笔记)
查看>>
H5浏览器播放RTMP直播流实现切换
查看>>
JavaScript局部变量和全局变量的理解
查看>>
Maven的配置文件setting.xml
查看>>
有趣的机器学习:最简明入门指南
查看>>
HTTP协议详解(二)
查看>>
初学Socket
查看>>
由select引发的思考
查看>>
WCF 内置跟踪日志
查看>>
坐标旋转
查看>>
数字签名和数字证书
查看>>
iOS更改项目名称的详细步骤
查看>>
LeetCode Delete Node in a Linked List
查看>>
一个模仿CCTV 5+体育台上的选项卡
查看>>
Window Classes in Win32
查看>>
洛谷 P4071 [SDOI2016]排列计数
查看>>
AngularJS 教程
查看>>
小运算
查看>>