Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.util.*;

public class Main {
    public static <V extends Comparable<V>> V max(List<V> arg) {
        if (arg == null) {
            return null;
        }

        if (arg.size() == 1) {
            return arg.get(0);
        }

        V max = arg.get(0);
        for (V each : arg) {
            if (max.compareTo(each) < 0) {
                max = each;
            }
        }
        return max;
    }
}