Showing stack overflow can you please correct it and explain why it is showing so

Scanner scn = new Scanner(System.in);
	int N =scn.nextInt();
	int[] arr=new int[N];

for(int i=0 ; i<N ; i++)
{
arr[i]=scn.nextInt();
}
int M =scn.nextInt();
int[] ans=allindices(arr,M);
display(ans);
}
public static int[] allindices(int[] arr, int M)
{
int si=0;
int count=0;
if(si==arr.length)
{
int[] base=new int[count];
return base;
}
int[] indices=null;

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

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

}
return indices;
}
public static void display(int[] ans)
{
for(int i=0 ; i<ans.length;i++)
{
System.out.print(ans[i]);
}
}
}

please share your code after saving it on ide.codingblocks.com