LargestInteger.java 530B

123456789101112131415161718192021222324252627
  1. import java.lang.Math;
  2. import java.util.Arrays;
  3. public class LargestInteger {
  4. public Integer findLargestNumberUsingConditional(Integer[] integers){
  5. int largest = integers[0];
  6. for(int num : integers){
  7. largest = num;
  8. }
  9. return largest;
  10. }
  11. public Integer findLargestNumberUsingMathMax(Integer[] integers){
  12. int[] tab = {};
  13. int largest = Arrays.stream(tab).max().getAsInt();
  14. return largest;
  15. }
  16. }