1234567891011121314151617181920212223 |
-
-
- public class LargestInteger {
-
- public Integer findLargestNumberUsingConditional(Integer[] integers){
- int maxNum = integers[0];
- for(int i=1; i<integers.length;i++){
- int newMax = integers[i] >= integers[i-1] ? integers[i] : maxNum;
- maxNum=newMax;
- }
- return maxNum;
- }
-
- public Integer findLargestNumberUsingMathMax(Integer[] integers){
- int maxNum = integers[0];
- for(int i=1; i<integers.length;i++){
- int newMax = Math.max(integers[i],maxNum);
- maxNum=newMax;
- }
- return maxNum;
- }
- }
|