1234567891011121314151617181920212223 |
-
-
- public class LargestInteger {
-
- public Integer findLargestNumberUsingConditional(Integer[] integers){
- int largestInt=0;
- if ((integers[0] > integers[1]) && (integers[0] > integers[2])){
- largestInt = integers[0];
- } else if ((integers[1] > integers[0]) && (integers[1] > integers[2])){
- largestInt = integers[1];
- } else if ((integers[2] > integers[0]) && (integers[2] > integers[1])){
- largestInt = integers[2];
- }
- return largestInt;
- }
-
- public Integer findLargestNumberUsingMathMax(Integer[] integers){
- int tempLargest = Math.max(integers[0], integers[1]);
- int largestInt = Math.max (tempLargest, integers[2]);
- return largestInt;
- }
- }
|