LargestInteger.java 636B

1234567891011121314151617181920212223242526272829
  1. public class LargestInteger {
  2. public Integer findLargestNumberUsingConditional(Integer[] integers){
  3. Integer max = new Integer(Integer.MIN_VALUE);
  4. for (int i = 0; i <integers.length; i++) {
  5. if (max < integers[i]) {
  6. max = integers[i];
  7. }
  8. }
  9. return max;
  10. }
  11. public Integer findLargestNumberUsingMathMax(Integer[] integers){
  12. int max = Integer.MIN_VALUE;
  13. for (int i = 0; i < integers.length; i++) {
  14. max = Math.max(max, integers[i]);
  15. }
  16. return max;
  17. }
  18. }