| Author |
generic doubt
|
sundar sankar
Ranch Hand
Joined: May 30, 2007
Posts: 42
|
|
Hi All, /*interface as line1 { void ge(); }*/ class a1// implements as line 2 { int a=12; public void ge() { System.out.println("form the class a"); System.out.println(a); } } class a2 extends a1 { int a=120; public void ge() { System.out.println("form the class b"); System.out.println(a); } } class c <T>// extends a1> { T gen; public c(T va) { this.gen=va; } public void set() { System.out.println(gen+" ," +gen.getClass()); gen.ge(); } } class d { public static void main(String ava[]) { a1 ad=new a1(); c<a1> ad1=new c<a1>(ad); ad1.set(); } } iN the above program if i uncomment the line1(interface) and line 2 i got compile time error as method gen.ge() not found in java.object.lang. please help me in this regard thanks in advance sankar
|
 |
Keith Lynn
Ranch Hand
Joined: Feb 07, 2005
Posts: 2341
|
|
My guess is that when you uncommented those lines, you forgot to put the bound on the type parameter of c. This code will compile. [ June 26, 2007: Message edited by: Keith Lynn ]
|
 |
sundar sankar
Ranch Hand
Joined: May 30, 2007
Posts: 42
|
|
Iam getting compile error with comment in line 1 and line 2 thanks sankar
|
 |
 |
|
|
subject: generic doubt
|
|
|