/*class Book {
String title;
String author;
void show() { System.out.println(title + " " + author); }
//메소드
public Book() {
this("","");
System.out.println("생성자 호출 완료");
}
//생성자1
public Book(String t) { //생성자
this(t,"작자미상");
}
//생성자2
public Book(String title, String author) { //생성자2
this.title = title; //this title은 나(class)의 변수, 그냥 title은 String title = 매개변수
this.author = author;
}
//생성자3
}
public class Main {
public static void main(String [] args) {
Book littlePrince = new Book("어린왕자","생텍쥐페리");
Book lovestory = new Book("춘향전");
Book emptyBook = new Book();
lovestory.show();
}
}
class Main {
int id;
public Main() {
this(0);
System.out.println("생성자 호출");
}
public Main(int x) { // 생성자는 반환형이 없다!!
this.id = x;
}
public static void main(String[] args) {
}
} */
class Main {
int x;
public void setX(int x) {
this.x = x;
}
public int getX() {
return x;
}
public Main(int x) {
this.x = x;
}
public static void main(String[] args) {
Main a = new Main(1);
int n = a.getX();
System.out.println(n);
}
}