12345678910111213141516171819202122232425262728293031 |
-
- import java.lang.Math;
- public class LargestInteger {
-
- public Integer findLargestNumberUsingConditional(Integer[] integers){
- for(int i = 0;i <= 2 ;i++)
- {
- if(integers[i] > integers [i+1] && integers[i] > integers[i+2])
- {
- return integers[i];
- }
- else if(integers[i+1] > integers[i] && integers[i+1] > integers[i+2])
- {
- return integers[i+1];
- }
- else
- {
- return integers[i+2];
- }
- }
- return 0;
- }
-
- public Integer findLargestNumberUsingMathMax(Integer[] integers){
- int max = Math.max(integers[0],integers[1]);
- int max1 = Math.max(max,integers[2]);
- return max1;
- }
- }
-
|