728x90 300x250 블럭1 JAVA 클래스 멤버변수 초기화 ※ 클래스 멤버변수 초기화 방법 3가지 소개 1. 명시적 초기화(Explicit initialization) 1 2 3 4 class Car { int door = 4; Engine e = new Engine(); } cs 2. 생성자(Constructor) 1 2 3 4 5 6 7 8 9 10 11 class Car { String color; String gearType; int door; Car(String color, String gearType, int door) { this.color = color; this.gearType = gearType; this.door = door; } } Colored by Color Scripter cs 3. 초기화 블럭(Initialization block) .. 2018. 12. 29. 이전 1 다음 728x90 300x250