Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Execution {
- public static void main(String[] args) {
- System.out.println(max(2, 5, 6, 7));
- System.out.println(max("apples", "lost", "chicken", "tots"));
- }
- public static <T extends Comparable<T>> T max(T a, T b, T c, T d){
- T m = a;
- if(b.compareTo(a)>0){
- m = b;
- }
- if(c.compareTo(b)>0){
- m = c;
- }
- if(d.compareTo(c)>0){
- m = d;
- }
- return m;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement