Whats wrong in my code?

import java.util.*;
public class Main {
public static void main(String args[]) {
// Your Code Here
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();

	int[] arr = new int[n];
	for(int i=0;i<n;i++){
		arr[i] = sc.nextInt();
	}

	int target = sc.nextInt();

	int[] ans = allIndices(arr,0,target,0);
	for(int val : ans){
		System.out.println(val);
	}
}

public static int[] allIndices(int[] arr ,int si, int target,int count){

	if(si==arr.length){
		int[] bc = new int[count];
		return bc;
	}

	//point
	int[] indices = null;

	if(arr[si] == target){
		indices = allIndices(arr,si+1,target,count+1);
	}else{
		indices = allIndices(arr,si+1,target,count);
	}

	if(arr[si] == target){
		indices[count] = si;
	}

	return indices;
}

}

Hey @ParagKumar, you have error in the output format.
Your logic is completely correct.
Just match the answer to the expected output format.

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.