Powered by Ajaxy
Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Java: Find the largest element of an array

Java: Find the largest element of an array
{filelink=12321}

if (a.length == 0)
throw new NoSuchElementException();
T maxValue = a[0];
for (int i = 1; i < a.length; i++)
   if (maxValue.compareTo(a[i]) < 0)
     maxValue = a[i];

Users who found this page were searching for:

  • strikethrough font in java
  • how to add a weekday into a java code

No comments yet.

Leave a Comment