A method in a generic class can be overridden just like other class.
Example:
class Gen1
{ void getobj(T i){
System.out.println("this is Gen1\t"+i);}
};
class Gen2 extends Gen1
{ void getobj(T i){
System.out.println("this is Gen2\t"+i);
}
};
class demo
{
public static void main(String[] args){
Gen1 i=new Gen1();
i.getobj(new Integer(10));
No comments:
Post a Comment