LargestInteger.java 553B

1234567891011121314151617181920212223
  1. public class LargestInteger {
  2. public Integer findLargestNumberUsingConditional(Integer[] integers){
  3. int largest = 0;
  4. for (int i = 0; i < integers.length; i++){
  5. largest = integers[i] > largest ? integers[i] : largest;
  6. }
  7. return largest;
  8. }
  9. public Integer findLargestNumberUsingMathMax(Integer[] integers){
  10. int largest = 0;
  11. for (int i = 1; i < integers.length; i++) {
  12. largest = Math.max(integers[i], integers[i-1]);
  13. }
  14. return largest;
  15. }
  16. }