Java examples for java.lang:int
Returns the bigger of the two Integers.
/*/*w w w.j a v a2 s .com*/ * Copyright (c) 2015-2016 QuartzDesk.com. * Licensed under the MIT license (https://opensource.org/licenses/MIT). */ //package com.java2s; public class Main { public static void main(String[] argv) throws Exception { Integer i1 = 2; Integer i2 = 2; System.out.println(max(i1, i2)); } /** * Returns the bigger of the two Integers. A null Integer * is treated as smaller then {@link Integer#MIN_VALUE}. * * @param i1 the first Integer. * @param i2 the second Integer. * @return the bigger of the two Integers. */ public static Integer max(Integer i1, Integer i2) { if (i1 != null && i2 != null) return i1 > i2 ? i1 : i2; return i1 == null ? i2 : i1; } /** * Returns the bigger value of the two int arguments. * * @param i1 the first int. * @param i2 the second int. * @return the bigger value of the two int arguments. */ public static int max(int i1, int i2) { return i1 > i2 ? i1 : i2; } }