Please check code line no. 7

public class Allindices
{
public static void main(String[] args)
{
int[] arr={3,8,1,8,8,4};
int[] res=allIndices(arr,0,8,0);
display(res); //Why System.out.println(res); doesn’t work?
}
public static int[] allIndices(int[] arr,int i, int data, int count)
{
if(i==arr.length)
{
int[] base=new int[count];
return base;
}
int[] indices=null;
if(arr[i]==data)
{
indices=allIndices(arr,i+1,data,count+1);
}
else
{
indices=allIndices(arr,i+1,data,count);
}
if(arr[i]==data)
{
indices[count]=i;

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

}

Hey @jdkatti
Wait I see it

Sir, please chech the commented line

System.out.println(res); // you cannot print Array directly just print address here
In Java, arrays don’t override toString() , so if you try to print one directly, you get the className + ‘@’ + the hex of the hashCode of the array,

Yes sir, got it
I need to call another function as display to print the array

@jdkatti
yes its correct