1
0
mirror of https://github.com/Snailclimb/JavaGuide synced 2025-06-16 18:10:13 +08:00

Update modify some descriptions

This commit is contained in:
SnailClimb 2019-03-30 13:00:45 +08:00 committed by GitHub
parent cac7b1af24
commit 4fe24cba87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -92,15 +92,13 @@ public class Sub extends Super {
**使用 this 和 super 要注意的问题:**
- super 调用父类中的其他构造方法时,调用时要放在构造方法的首行!this 调用本类中的其他构造方法时,也要放在首行。
- 在构造器中使用 `super` 调用父类中的其他构造方法时,该语句必须处于构造器的首行,否则编译器会报错。另外,this 调用本类中的其他构造方法时,也要放在首行。
- this、super不能用在static方法中。
**简单解释一下:**
被 static 修饰的成员属于类,不属于单个这个类的某个对象,被类中所有对象共享。而 this 代表对本类对象的引用,指向本类对象;而 super 代表对父类对象的引用,指向父类对象;所以, **this和super是属于对象范畴的东西而静态方法是属于类范畴的东西**
## 参考
- https://www.codejava.net/java-core/the-java-language/java-keywords