Here's the implementation of the `c4` function in the `JavaIntro_Challenges` class:
```java
public class JavaIntro_Challenges {
public static int[] c4(String input) {
int oddCount = 0;
int evenCount = 0;
for (char ch : input.toCharArray()) {
if (Character.isDigit(ch)) {
int digit = Character.getNumericValue(ch);
if (digit % 2 == 0) {
evenCount++;
} else {
oddCount++;
}
}
}
return new int[] { oddCount, evenCount };
}
public static void main(String[] args) {
// Test cases
int[] result1 = c4("48975165");
System.out.println(Arrays.toString(result1)); // [5, 3]
int[] result2 = c4("286644000");
System.out.println(Arrays.toString(result2)); // [0, 9]
int[] result3 = c4("5Hello78World00!!");
System.out.println(Arrays.toString(result3)); // [2, 3]
int[] result4 = c4("No-Digits_Are Here");
System.out.println(Arrays.toString(result4)); // [0, 0]
int[] result5 = c4("");
System.out.println(Arrays.toString(result5)); // [0, 0]
}
}
```
The `c4` function takes a string `input` and analyzes each character in the string. It counts the odd and even digits and returns an integer array with the odd count as the first value and the even count as the second value.
In the function, we initialize `oddCount` and `evenCount` variables to keep track of the counts. We loop through each character in the input string using a `for-each` loop. For each character, we check if it is a digit using `Character.isDigit(ch)`. If it is a digit, we convert it to an integer using `Character.getNumericValue(ch)`. We then check if the digit is odd or even by checking if `digit % 2 == 0`. Based on the result, we increment the corresponding count variable.
Finally, we create a new integer array with the odd count and even count, and return it.
In the `main` method, you can see example test cases that call the `c4` function and print the results. You can add more test cases as needed to further validate the function.