We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7a425a2 commit f111af8Copy full SHA for f111af8
docs/book/06-Housekeeping.md
@@ -437,7 +437,7 @@ public class BananaPeel {
437
438
```java
439
Banana.peel(a, 1)
440
-Banana.peel(b, 1)
+Banana.peel(b, 2)
441
```
442
443
这是在内部实现的,你不可以直接这么编写代码,编译器不会接受,但能说明到底发生了什么。假设现在在方法内部,你想获得对当前对象的引用。但是,对象引用是被秘密地传达给编译器——并不在参数列表中。方便的是,有一个关键字: **this** 。**this** 关键字只能在非静态方法内部使用。当你调用一个对象的方法时,**this** 生成了一个对象引用。你可以像对待其他引用一样对待这个引用。如果你在一个类的方法里调用其他该类中的方法,不要使用 **this**,直接调用即可,**this** 自动地应用于其他方法上了。因此你可以像这样:
0 commit comments