this

멤버 변수와 메서드의 매개변수의 이름이 같으면 둘을 어떻게 구분해야할까?

initMember(String name, int age, String grade){
    this.name = name;
    this.age = age;
    this.grade = grade;
}

this는 인스턴스 자신을 가리킴으로써 멤버 변수와 지역 변수가 이름이 같은 경우 활용할 수 있다.

Last updated