• Post Reply Bookmark Topic Watch Topic
  • New Topic

Regarding Wrapper Classes  RSS feed

 
Siva Rsrk
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Every One,

When iam using Wrapper Classes,
i got following error ,
GenericEx1.java:6: cannot find symbol
symbol : class T
location: class GenericEx1
T it=obj.add(3,4);

Below is My Application

public class GenericEx1
{
public static void main(String[] args)
{
GenOne obj=new GenOne();
T it=obj.add(3,4);
System.out.println("i Val---"+it);
}

}
class GenOne<T>
{
public T add(T i, T j) {
System.out.println("i--"+i+"--j--"+j);
return i;
}
}



When i change my Application to like this

public class GenericEx1<T>
{
public static void main(String[] args)
{
GenOne obj=new GenOne();
T it=obj.add(3,4);
System.out.println("i Val---"+it);
}

}
class GenOne<T>
{
public T add(T i, T j) {
System.out.println("i--"+i+"--j--"+j);
return i;
}
}


This is gots following error

GenericEx1.java:6: non-static class T cannot be referenced from a static context

T it=obj.add(3,4);

Please any one can help me regarding this problem and how to use Wrappers in a very better way
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
" Siva Rsrk"
Please check your private messages for an important administrative matter
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!