LargestInteger.java 562B

123456789101112131415161718192021222324252627
  1. import java.util.*;
  2. public class LargestInteger {
  3. public Integer findLargestNumberUsingConditional(Integer[] integers){
  4. int max=0;
  5. for(int i=0;i<(integers.length);i++)
  6. {
  7. if(integers[i]>max)
  8. {
  9. max=integers[i];
  10. }
  11. }
  12. return max;
  13. }
  14. public Integer findLargestNumberUsingMathMax(Integer[] integers){
  15. int max=integers[0];
  16. for(int i=1;i<integers.length;i++)
  17. {
  18. max=Math.max(integers[i],max);
  19. }
  20. return max;
  21. }
  22. }