GenericMath { public static <N extends Comparable<N>> N max(N a, N b) { return a.compareTo(b) > 0 ? a : b; }  @SuppressWarnings("unchecked") static N add(N a, M b); @SuppressWarnings("unchecked") static N subtract(N a, M b); @SuppressWarnings("unchecked") static N multiply(N a, M b); @SuppressWarnings("unchecked") static N divide(N a, M b); static N min(N a, N b); static N max(N a, N b); static BigInteger bigInt(Number n); static BigDecimal bigDec(Number n);  }
@Test public void max_Integer() { Integer a = 42; Integer b = 100; assertEquals(b, max(a, b)); assertEquals(b, max(b, a)); }
@Test public void max_Long() { Long a = 42L; Long b = 100L; assertEquals(b, max(a, b)); assertEquals(b, max(b, a)); }
@Test public void max_Float() { Float a = 42F; Float b = 100F; assertEquals(b, max(a, b)); assertEquals(b, max(b, a)); }
@Test public void max_Double() { Double a = 42D; Double b = 100D; assertEquals(b, max(a, b)); assertEquals(b, max(b, a)); }
@Test public void max_String() { String a = "a"; String b = "b"; assertEquals(b, max(a, b)); assertEquals(b, max(b, a)); }