java this

this 代表什么

this 应用场景

 https://docs.oracle.com/javase/tutorial/java/javaOO/thiskey.html

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值