LargestInteger.java 637B

1234567891011121314151617181920212223242526272829
  1. public class LargestInteger {
  2. public Integer findLargestNumberUsingConditional(Integer[] integers){
  3. int highest= integers[0];
  4. if(integers[1] > highest){
  5. highest = integers[1];
  6. if (integers[2] > highest){
  7. highest = integers[2];
  8. }
  9. }
  10. else if (integers[2] > highest){
  11. highest = integers[2];
  12. }
  13. return highest;
  14. }
  15. public Integer findLargestNumberUsingMathMax(Integer[] integers){
  16. int highest= Math.max(Math.max(integers[0],integers[1]), integers[2]);
  17. return highest;
  18. }
  19. }