Java this關鍵字總結

Java中this關鍵字表明對當前對象的一個引用,this用來調用屬性、方法以及本類中的構造方法。 下面咱們經過幾個例子來詳述一下this的用法:java public class Student{ String name; void doHomework(){ System.out.println(this.name+"正在作做業"); } void speak(){ new S
相關文章
相關標籤/搜索