-
DAY3. 설계도로 객체 생성하고, 참조하기기록 2022. 9. 8. 16:59
설계도(클래스)로 객체 생성하고, 참조하기
KeyboardReader reader = new KeyboardReader();
- reader는 KeyboardReader 타입의 변수다.
reader는 KeyboardReader 설계도로 생성된 객체의 주소값을 담는 변수다.
- new 예약어
- new KeyboardReader()는 KeyboardReader 설계도로 객체를 생성한다.
- reader = new KeyboardReader()은 생성된 객체의 주소값을 reader 변수에 대입한다.
- reader변수는 생성된 KeyboardReader 객체를 참조한다.
- reader변수를 이용해서 생성된 KeyboardReader 객체의 공개된 속성과 기능을 사용할 수 있다.
- reader.getInt();
reader변수가 참조하는 KeyboardReader객체의 getInt() 기능을 실행한다. (메소드를 호출한다)'기록' 카테고리의 다른 글
DAY6. 배열 (0) 2022.09.09 DAY6. while문 (0) 2022.09.09 DAY4. 제어문과 반복문, 변수의 스코프 (0) 2022.09.08 DAY2. 변수의 데이터 타입, 식별자 작성 관례, 자바가상머신 메모리 구조 (0) 2022.09.08 DAY1. 자바의 특징 (0) 2022.09.08