LargestInteger.java 533B

12345678910111213141516171819
  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 = 0; i < integers.length; i++){
  12. largest = Math.max(integers[i], largest);
  13. }
  14. return largest;
  15. }
  16. }