package testjava;
public class Board {
private static int bno; // 필드
public int setboard() { return this.bno;} // 메소드1
public int getboard() {return this.bno;} // static 메소드2
}
package testjava;
public class Board2 {
public static int bno;
private static Board2 board = new Board2(); // 싱글톤
public static Board2 getInstance() {return board;}
public int setboard () {return bno;} // 메소드1
public int getboard() { return bno;} // static 메소드2
}
package testjava;
public class test {
// getboard() 와 setboard() [호출하는 방법 -5가지]
// 1. new 를 쓰는방법
Board2 boardtest = new Board2();
int testvalue1 = boardtest.getboard();
int testvalue2 = boardtest.setboard();
// 2. @Autowird
// @Autowird
private Board2 board3;
int testvalue5 = board3.getboard();
int testvalue6 = board3.setboard();
// 싱글톤
Board2 boardObject = Board2.getInstance();
int testvalue3 = boardObject.getboard();
int testvalue4 = boardObject.setboard();
}