We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cac7b1a commit 4fe24cbCopy full SHA for 4fe24cb
docs/java/Basis/final、static、this、super.md
@@ -92,15 +92,13 @@ public class Sub extends Super {
92
93
**使用 this 和 super 要注意的问题:**
94
95
-- super 调用父类中的其他构造方法时,调用时要放在构造方法的首行!this 调用本类中的其他构造方法时,也要放在首行。
+- 在构造器中使用 `super()` 调用父类中的其他构造方法时,该语句必须处于构造器的首行,否则编译器会报错。另外,this 调用本类中的其他构造方法时,也要放在首行。
96
- this、super不能用在static方法中。
97
98
**简单解释一下:**
99
100
被 static 修饰的成员属于类,不属于单个这个类的某个对象,被类中所有对象共享。而 this 代表对本类对象的引用,指向本类对象;而 super 代表对父类对象的引用,指向父类对象;所以, **this和super是属于对象范畴的东西,而静态方法是属于类范畴的东西**。
101
102
-
103
104
## 参考
105
106
- https://www.codejava.net/java-core/the-java-language/java-keywords
0 commit comments