DulcetAirman icon

OptionalInt

DulcetAirman | PRO | 08/28/18 06:53:53 PM UTC | 0 ⭐ | 576 👁️ | Never ⏰ | []
Java |

350 B

|

None

|

0 👍

/

0 👎

  public static OptionalInt max1(int... a) {
    return Arrays.stream(a).max();
  }
 
  public static OptionalInt max2(int... a) {
    if (a == null || 0 == a.length)
      return OptionalInt.empty();
    int max = a[0];
    for (int i = 1; i < a.length; i++) {
      if (a[i] > max)
        max = a[i];
    }
    return OptionalInt.of(max);
  }

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎