LargestInteger.java 511B

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