mystery6 methods

public static int countNegatives(int[] arr)
{
    return countNegatives(arr, 0);
}

private static int countNegatives(int[] arr, int index)
{
    if(index >= arr.length)
        return 0;
    
    int count = countNegatives(arr, index + 1);
    
    if(arr[index] < 0)
        count++;
    
    return count;
}

The methods count the number of negative values in arr.

mystery5 solution
mystery7 solution
Exercises
All solutions