Not accepting answer for given problem

public static ArrayList All_idx(int n,int a[],int m,int i)
{
if(i==a.length)
{
ArrayList bs=new ArrayList<>();
return bs;
}
ArrayList ans=new ArrayList<>();
ArrayList aa=All_idx(n, a, m, i+1);

if(a[i]==m)
{
    aa.add(i);
}
ans=aa;
return ans;

}

public static void main(String[] args) {
    
	Scanner sc=new Scanner(System.in);

// String str;
// str=sc.nextLine();
//
// System.out.println(Pi_rem(str));

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

ArrayList<Integer> aa=All_idx(n, a, m, 0);

Collections.reverse(aa);
System.out.println(aa);
}

}

it is becoz u are printing arraylist
it print the output like [1,3]

so just print its value 1 3

but in the qn u have return an array
so pls try to implement it using an array
u will learn something new

becoz in the arraylist u dont have think about size of the list
but in array we require the size of the array

so pls try it by using array

hope this will help u
pls rate my work
pls

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.