this
📌 this
① 자기 자신의 메모리를 가리킴.
...
// 생성자
public Student(int id, String name, int birth, String phoneNumber) {
this.id = id;
this.name = name;
this.birth = birth;
this.phoneNumber = phoneNumber;
}
...
② 생성자에서 다른 생성자를 호출함.
...
public Student() { // 디폴트 생성자.
this(-1, "없음");
}
public Student(int id, String name) { // 생성자.
this.id = id;
this.name = name;
}
...
③ 자기 자신의 주소를 반환함.
'Java > Java' 카테고리의 다른 글
[Java] 메소드 오버로딩(Method Overloading) (0) | 2022.10.13 |
---|---|
[Java] static(클래스 변수, 클래스 메소드) (0) | 2022.10.13 |
[Java] 정보 은닉(Information Hiding)과 접근 수준 지시자(Access-level Modifiers) (0) | 2022.10.13 |
[Java] 생성자(Constructor)와 디폴트 생성자(Default Constructor) (0) | 2022.10.13 |
[Java] 클래스(Class)와 인스턴스, 참조 변수(Reference Variable) (0) | 2022.10.13 |
댓글