LargestInteger.java 851B

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