public class dailyCode {
public interface Callback { public void getOdd(); public void getEven(); }
public static void main(String[] args){ dailyCode.Callback callback = new dailyCode.Callback() {
@Override public void getOdd() { System.out.println("getOdd"); }
@Override public void getEven() { System.out.println("getEven"); } }; for(int i=1; i<=5; i++){ if(i%2==0) { callback.getEven(); } else { callback.getOdd(); } } } } |
'프로그래밍 > JAVA' 카테고리의 다른 글
Generics and Wildcard (0) | 2016.11.20 |
---|---|
arraycopy Example (0) | 2016.11.19 |
scheduleAtFixedRate vs. scheduleWithFixedDelay (0) | 2016.11.18 |
Singleton Design Pattern (0) | 2016.11.16 |
초기화 블록 (Initialization Block) (0) | 2016.11.15 |
HashSet 예제 (0) | 2016.11.15 |
ArrayList 예제 (0) | 2016.11.14 |