Here you can find the source of min(T a, T b)
Parameter | Description |
---|---|
T | the object type |
a | item that compareTo is called on, may be null |
b | item that is being compared, may be null |
public static <T extends Comparable<? super T>> T min(T a, T b)
//package com.java2s; //License from project: Apache License public class Main { /**/*w w w .j ava 2 s . co m*/ * Compares two objects finding the minimum. * * @param <T> the object type * @param a item that compareTo is called on, may be null * @param b item that is being compared, may be null * @return the minimum of the two objects, null if both null */ public static <T extends Comparable<? super T>> T min(T a, T b) { if (a != null && b != null) { return a.compareTo(b) <= 0 ? a : b; } if (a == null) { if (b == null) { return null; } else { return b; } } else { return a; } } }