LargestInteger.java 753B

1234567891011121314151617181920212223
  1. public class LargestInteger {
  2. public Integer findLargestNumberUsingConditional(Integer[] integers){
  3. int largestInt=0;
  4. if ((integers[0] > integers[1]) && (integers[0] > integers[2])){
  5. largestInt = integers[0];
  6. } else if ((integers[1] > integers[0]) && (integers[1] > integers[2])){
  7. largestInt = integers[1];
  8. } else if ((integers[2] > integers[0]) && (integers[2] > integers[1])){
  9. largestInt = integers[2];
  10. }
  11. return largestInt;
  12. }
  13. public Integer findLargestNumberUsingMathMax(Integer[] integers){
  14. int tempLargest = Math.max(integers[0], integers[1]);
  15. int largestInt = Math.max (tempLargest, integers[2]);
  16. return largestInt;
  17. }
  18. }