Generic Method
public class GenericMethod {
public static <E> void display(E item){ /* display is a generic method which can
accept and display any type of argument*/
System.out.println(item);
}
public static void main(String[] args) {
System.out.print("Integer Value:");
display(1);
System.out.print("String Value:");
display("hai");
System.out.print("Double Value:");
display(10.05);
}
}
Output:
Integer Value:1
String Value:hai
Double Value:10.05