today i start learning generic.
i m from c and C++ background so i have some knowledge about template and in java the generics is similar to template in c++.
right?
look at my code carefully .....
[code=java]
public class MyGenericClass< e>
{
private e data;
public MyGenericClass( e d){data = d;}
public e getData()
{
return e;
}
}
//With this code no problem
//but the problem is when i access this class.
//this is the code part
MyGenericClass< int> c = new MyGenericClass< int>(100);
//Here the compiler tells that the type is not found.
//I understand primitive type is not supported, only class or interface type is //suppoerted.
[/code]
could anyone tell me why sun did this?
kind regards,
dmjpro.
i m from c and C++ background so i have some knowledge about template and in java the generics is similar to template in c++.
right?
look at my code carefully .....
[code=java]
public class MyGenericClass< e>
{
private e data;
public MyGenericClass( e d){data = d;}
public e getData()
{
return e;
}
}
//With this code no problem
//but the problem is when i access this class.
//this is the code part
MyGenericClass< int> c = new MyGenericClass< int>(100);
//Here the compiler tells that the type is not found.
//I understand primitive type is not supported, only class or interface type is //suppoerted.
[/code]
could anyone tell me why sun did this?
kind regards,
dmjpro.
Comment