This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

generic doubt

 
sundar sankar
Ranch Hand
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2399
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Iam getting compile error with comment in line 1 and line 2
thanks
sankar
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic