class GenericClass { private double val; <T extends Number> GenericClass(T arg) { val = arg.doubleValue(); } void showValue() { System.out.println("val: " + val); } } public class MainClass { public static void main(String args[]) { GenericClass test = new GenericClass(100); GenericClass test2 = new GenericClass(123.5F); test.showValue(); test2.showValue(); } }
val: 100.0 val: 123.5