renamed 7 to 8A and 8B and 8C added as well
This commit is contained in:
16
GenericMethod8C.java
Normal file
16
GenericMethod8C.java
Normal file
@@ -0,0 +1,16 @@
|
||||
public class GenericMethod8C {
|
||||
public static <A extends Comparable <A>> A findMax(A x, A y){
|
||||
return x.compareTo(y) > 0 ? x : y;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Integer maxInt = findMax(5,10);
|
||||
System.out.println("Maximum of 5 and 10 is: " + maxInt);
|
||||
|
||||
Double maxDouble = findMax(6.7, 9.8);
|
||||
System.out.println("Maximum of 6.7 and 9.8 is: " + maxDouble);
|
||||
|
||||
String maxString = findMax("pineapple", "appleeeeeeeeee");
|
||||
System.out.println("Maximum of 'pineapple' and 'apple' is: " + maxString);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user