added till 8th b and c

This commit is contained in:
Misa
2026-01-29 15:26:29 +05:30
parent fd0c995cd6
commit 7f14e4b061
9 changed files with 41 additions and 0 deletions

19
GenericMethod2.java Normal file
View File

@@ -0,0 +1,19 @@
public class GenericMethod2
{
public static <T extends Comparable<T>> T findMax(T x, T y)
{
return x.compareTo(y) > 0 ? x : y;
}
public static void main(String[] args)
{
Integer maxInt = findMax(5,10);
System.out.println("Maxim7um of 5 and 10 is: " +maxInt);
Double maxDouble = findMax(3.5, 7.8);
System.out.println("Maximum of 3.5 and 7.8 is: " +maxDouble);
String maxString = findMax("apple", "banana");
System.out.println("Maximum of 'apple' and 'banana' is: " +maxString);
}
}