added program 8C and screenshot for it

This commit is contained in:
2026-01-29 15:10:48 +05:30
parent 03ec87b45c
commit 19f60776c9
2 changed files with 15 additions and 0 deletions

BIN
Screenshots/program8C.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

15
methodp1.java Normal file
View File

@@ -0,0 +1,15 @@
// 8C
public class methodp1{
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("Maximum 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);
}
}