public class AllIndex {
public static int[] check(int[] arr, int i, int n, int count) {
if (arr.length == i) {
int[] base = new int[count];
return base;
}
int[] ans = null;
if (arr[i]==n) {
ans = check(arr, i+1, n, count+1);
} else {
ans = check(arr, i+1, n, count);
}
if(arr[i]==n) {
ans[count] = i;
}
return ans;
}
public static void main(String[] args) {
int[] arr = {3,8,1,8,8,4};
int[] res = check(arr, 0, 8, 0);
System.out.println(res);
}
I wrote the above code for the All Indices problem and my output is cming out to be as follows:
[I@15db9742
I’m not able to debug this issue. Please help me out