LargestInteger.java 524B

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