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
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