aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes generic doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "generic doubt" Watch "generic doubt" New topic
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: 2367
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: generic doubt