且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Java和PHP中的这个关键字

更新时间:2022-02-02 09:26:15

在Java中,您并不总是需要说'这个'Java会解决它。当你需要说这个时,唯一的情况是局部变量与实例变量的名称相同,在这种情况下,如果你不说this.var

In Java you don't always need to say 'this' Java will figure it out. The only situation when you need to say this is when the local variable is the same name as instance variable, in which case Java will use local variable if you don't say this.var

但即使在Java中没有必要,你仍然可以说this.var,它会让你更好地理解代码。

But you still can say this.var even when it's not necessary in Java if it makes you understand the code better.