package class02;
class Point {
	int x;
	int y;
	void showInfo() {
		System.out.println("P(" + this.x + "," + this.y + ")");
	}
	Point() {
		this(0, 0);
		System.out.println("기본 생성자");
	}
	Point(int x) {
		this.x = x;
		this.y = x;
	}
	Point(int x, int y) {
		this.x = x;
		this.y = y;
	}
}
public class Test03 {
	public static void main(String[] args) {
		Point p1 = new Point(10, 20);
		Point p2 = new Point();
		Point p3 = new Point(1);
		p1.showInfo();
		p2.showInfo();
		p3.showInfo();
	}
}'개발자노트' 카테고리의 다른 글
| 클래스) 멤버 변수와 클래스 변수의 차이 이해 (0) | 2022.06.17 | 
|---|---|
| 클래스)생성자와 기본 생성자의 이해(학생 기록부) (0) | 2022.06.17 | 
| 클래스) 생성자와 기본 생성자의 관계(인자값) (0) | 2022.06.17 | 
| 클래스) stack영역과 heap 영역의 이해 (0) | 2022.06.17 | 
| 클래스)클래스 선언 복습 (0) | 2022.06.17 |