Ad
Code
Diff
  • import java.util.Arrays;
    import java.util.Collections;
    
    public class Kata
    {
        public static int findMax(int[] my_array)
        {
            int max = 0;
          for(int i = 0; i < my_array.length; i++)
          {
            if(my_array[i] > max)
            {
              max = my_array[i];
            }
          }
          return max;
        }
    }
    • import java.util.Arrays;
    • import java.util.Collections;
    • public class Kata {
    • public static int findMax(int[] my_array) {
    • // Write a method that returns the largest integer in the list.
    • // You can assume that the list has at least one element.
    • // without using ready implementation
    • return Arrays.stream(my_array)
    • .reduce(my_array[0], (acc, elem) -> acc > elem ? acc : elem);
    • public class Kata
    • {
    • public static int findMax(int[] my_array)
    • {
    • int max = 0;
    • for(int i = 0; i < my_array.length; i++)
    • {
    • if(my_array[i] > max)
    • {
    • max = my_array[i];
    • }
    • }
    • return max;
    • }
    • }