LargestInteger.java 512B

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