How to recursively count how many positive numbers are in an array in java without ArrayList?

To recursively count how many positive numbers are in an array in Java without using ArrayList, you can follow these steps:

1. Define a recursive method that takes in the array and the current index as parameters.
2. Base Case: If the current index is equal to the length of the array, return 0.
3. Recursive Case: Check if the element at the current index is positive. If it is, add 1 to the count and make a recursive call to the method with the next index. If it is not positive, make a recursive call to the method with the next index without modifying the count.
4. Return the count.

Here's the Java code that implements this approach:

```java
public class PositiveNumbersCount {

public static int countPositiveNumbers(int[] array, int currentIndex) {
// Base Case: If the current index is equal to the length of the array, return 0
if (currentIndex == array.length) {
return 0;
}

int count = 0;

// Recursive Case: Check if the element at the current index is positive
if (array[currentIndex] > 0) {
count = 1;
}

// Recursive call to the method with the next index
return count + countPositiveNumbers(array, currentIndex + 1);
}

public static void main(String[] args) {
int[] numbers = {1, -2, 3, -4, 5};

// Call the method to count the positive numbers
int positiveCount = countPositiveNumbers(numbers, 0);

System.out.println("The number of positive numbers in the array is: " + positiveCount);
}
}
```

In this example, the `countPositiveNumbers` method recursively counts the positive numbers in the given `numbers` array starting from index 0. The base case checks if the current index is equal to the length of the array, and if so, returns 0. In the recursive case, it checks if the element at the current index is positive, adds 1 to the count if it is, and makes a recursive call to the method with the next index. Finally, the main method calls the `countPositiveNumbers` method with the array and index as arguments and prints the result.