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