728x90
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | class AAA { public String toString() { return "Class A"; } } class BBB { public String toString() { return "Class B"; } } //class InstViewer { // int cnt = 0; // public <T/*, U*/> void view(T inst/*, U inst2*/){ // System.out.println(inst); //// System.out.println(inst2); // } //} class InstViewer { int cnt = 0; public <T, U> void view(T inst, U inst2){ System.out.println(inst); System.out.println(inst2); } } public class MethodMain { public static void main(String[] args) { AAA a = new AAA(); BBB b = new BBB(); InstViewer iv = new InstViewer(); // iv.<AAA>view(a); // iv.<BBB>view(b); iv.<AAA, BBB>view(a, b); } } | cs |
반응형
'SKILL > JAVA' 카테고리의 다른 글
자바 파일 입/출력 개념 정리 (출처: http://blog.daum.net/clamp83/51) (0) | 2017.12.19 |
---|---|
자바 Thread Synchronized 예제 (0) | 2017.12.19 |
자바 Animal 인터페이스 예제 (0) | 2017.12.19 |
자바 형변환 cast & instance of (0) | 2017.12.19 |
자바 연산자 기본예제 (0) | 2017.12.19 |