• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

generic doubt

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Iam getting compile error with comment in line 1 and line 2
thanks
sankar
 
Can you really tell me that we aren't dealing with suspicious baked goods? And then there is this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic