LargestInteger.java 531B

12345678910111213141516171819202122232425
  1. public class LargestInteger {
  2. public Integer findLargestNumberUsingConditional(Integer[] integers){
  3. Integer k = 0;
  4. for(int i=0; i<integers.length; i++){
  5. if (k<integers[i]){
  6. k = integers[i];
  7. }
  8. }
  9. return k;
  10. }
  11. public Integer findLargestNumberUsingMathMax(Integer[] integers){
  12. Integer k =0;
  13. for (int i = 0; i<integers.length; i++){
  14. k = Math.max(integers[i], integers[i++]);
  15. }
  16. return k;
  17. }
  18. }