LargestInteger.java 543B

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