All Indices Problem

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

ur approach seems fine

actually u are printing the array
so thats why it is printing the address of that arr.
so just print the arr elements

for(int val:res)
System.out.println(val);

hope this will help u
pls rate my work

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

I don’t see the option for the same