본문 바로가기

은닉:private 필드, getter, setter

데이터 보호

  • Encapsulation은 객체의 데이터를 숨기고 메서드를 통해만 변경하도록 하는 것입니다.
  • private blocks direct access from unrelated outside code. It does not validate values: constructors and mutating methods must enforce the object’s rules themselves.
  • 주요 도구로 사용되는 단어는 private와 public입니다.

Private balance는 getBalance 및 deposit를 통해 접근되며, 검증에는 명시적인 코드가 필요합니다

교재 자료

로그인 또는 계정 만들기

IGCSE, A-Level & AP