
생성자 예제 1 class Calculator { int left, right; public Calculator(int left, int right){ this.left = left; this.right = right; } public void sum(){ System.out.println(this.left+this.right); } public void avg(){ System.out.println((this.left+this.right)/2); } } 를 보면 클래스 이름과 같은 메서드를 이용하여 초기화할 수 있다. public Calculator(int left, int right){ this.left = left; this.left = right; } 이 class 이름과 같은 메서드를 생성자(c..