This keyword of Java

What is this?

When will it be used?

This is used when the object calling the method needs to be used in the method. For example:

At the same time, the following principles should be followed when using this in the constructor:

Person. java

Test. java

Final output:

Note: when creating a new object, Java will call the corresponding construction method according to the different parameters (type or number) passed. In the construction method, other construction methods will be called through this (parameter).

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>