妥協案
public class Values<T> { private T max, min; public Values(T max, T min) { this.max = max; this.min = min; } public T getMax() { return this.max; } public T getMin() { return this.min; } } package GenericsTest; public class ValueTester { public static void main(String[] args) { Values<Byte> byteVar = new Values<Byte>(Byte.MAX_VALUE, Byte.MIN_VALUE); Values<Integer> intVar = new Values<Integer>(Integer.MAX_VALUE, Integer.MIN_VALUE); Values<Double> doubleVar = new Values<Double>(Double.MAX_VALUE, Double.MAX_VALUE); System.out.println("Byte\t: " + byteVar.getMin() + "〜" + byteVar.getMax()); System.out.println("Int\t: " + intVar.getMin() + "〜" + intVar.getMax()); System.out.println("Long\t: " + doubleVar.getMin() + "〜" + doubleVar.getMax()); } }
と書いてみたけど、いまいちうまみない気がする。