How to create generic interfaces?

It is possible for interfaces to be generic. It is same as generic class.
interface Gen
T com(T obj1,T obj2);
class demo implements Gen
public T com(T obj1,T obj2){
if(obj1>obj2)return obj1;
return obj2;}
public static void main(String[] args){
Gen obj=new demo();
System.out.println("greater between 10 and 20 is:=" Integer(10),new Integer(20)));

No comments:

Post a Comment