Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static int max(int[] values) {
        if (values == null)
            throw new RuntimeException("The maximum of null is not defined!");
        if (values.length == 0)
            throw new RuntimeException("The maximum of an empty list is not defined!");

        int max = values[0];
        for (int i = 1; i < values.length; i++)
            if (max < values[i])
                max = values[i];
        return max;
    }
}