본문 바로가기

this 키워드

도입됨
교재 자료
이 주제용 영상 수업 영상 페이지 열기
7:20

클래스 생성

여기에는 이름, 학년, 등급이라는 세 개의 독립된 변수로 저장된 한 학생이 있습니다. 이것은 작동합니다. 이제 학생 천 명을 추가하십시오. 삼천 개의 변수가 필요합니다…

영어 내레이션 · 영어와 중국어 자막 전환 가능

이 수업의 내용

동영상 강의
English

A parameter can hide the field it should update

  • An object has name "Ada". setName(String name) runs name = name; with the argument "Bo".
  • Both unqualified names refer to the parameter, so the object still has "Ada". this.name = name assigns the parameter value to the field instead.
A parameter can hide the field it should update: in setName(String name), name = name assigns the parameter to itself, so the object keeps "Ada"; this.name = name assigns the parameter value "Bo" to the field

교재 자료

로그인 또는 계정 만들기

IGCSE, A-Level & AP