1234567891011121314151617181920212223242526272829303132 |
-
-
-
- public class LargestInteger {
- private Integer maxValue;
- private Integer currentValue;
- private Integer nextValue;
- public Integer findLargestNumberUsingConditional(Integer[] integers){
- maxValue = 0;
- currentValue = 0;
- nextValue =0;
- for (int i = 0; i < integers.length; i++) {
- currentValue = integers[i];
- if(currentValue > maxValue)
- maxValue = currentValue;
- }
- return maxValue;
- }
-
- public Integer findLargestNumberUsingMathMax(Integer[] integers){
- maxValue = 0;
- currentValue = 0;
- nextValue =0;
- for (int i = 0; i < integers.length-1; i++) {
- currentValue = integers[i];
- nextValue = integers[i + 1];
- maxValue = Math.max(currentValue, nextValue);
- }
- return maxValue;
- }
- }
|