I have 2 empty classes emp and reset . I have method in another class which will accept only these two classes these I need to achieve using generics . Both these classes are not related to each other in any manner.
package abstracta;
import generics.emp;
import generics.nonemp;
import generics.reset;
// A Simple Java program to show working of user defined
// Generic functions
class Test
{
// A Generic method example
static <T> void genericDisplay ( T element)
{
System.out.println(element.getClass().getName() +
" = " + element);
}
// Driver method
public static void main(String[] args)
{
// Calling generic method with Integer argument
genericDisplay(new emp());
// Calling generic method with String argument
genericDisplay(new reset());
genericDisplay(new nonemp());// should not accept . restrict this class
}
}
i want genericDisplay not to accept nonemp class