From 4fe24cba87d08d088a1a54b8d6da7298aaa6b89f Mon Sep 17 00:00:00 2001 From: SnailClimb Date: Sat, 30 Mar 2019 13:00:45 +0800 Subject: [PATCH] Update modify some descriptions --- ...nal\343\200\201static\343\200\201this\343\200\201super.md" | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git "a/docs/java/Basis/final\343\200\201static\343\200\201this\343\200\201super.md" "b/docs/java/Basis/final\343\200\201static\343\200\201this\343\200\201super.md" index 2c8a917f..e9008064 100644 --- "a/docs/java/Basis/final\343\200\201static\343\200\201this\343\200\201super.md" +++ "b/docs/java/Basis/final\343\200\201static\343\200\201this\343\200\201super.md" @@ -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 -- GitLab