Here you can find the source of min(T c1, T c2)
Parameter | Description |
---|---|
c1 | First value to be compared |
c2 | Second value to be compared |
public static <T extends Comparable<T>> T min(T c1, T c2)
//package com.java2s; /*//from w w w .j ava 2 s .co m * Copyright 2014 Maxim Dominichenko * * Licensed under The MIT License (MIT) (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * https://github.com/domax/gwt-dynamic-plugins/blob/master/LICENSE * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ public class Main { /** * Gets minimal value between given two. * * @param c1 * First value to be compared * @param c2 * Second value to be compared * @return First value will be returned if given {@code c1} is less or equal to {@code c2}. {@code null} value is * considered as less than not {@code null} one. */ public static <T extends Comparable<T>> T min(T c1, T c2) { if (c1 == c2) return c1; if (c1 == null) return c1; if (c2 == null) return c2; return c1.compareTo(c2) <= 0 ? c1 : c2; } }