Having error NullPointerException

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

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

    int[] indices = null;
    if (arr[si] == data) indices = allIndices(arr, si + 1, data, count + 1);

    else allIndices(arr, si + 1, data, count);

    if (arr[si] == data) if (indices != null) {
        indices[count] = si; //TODO: Here is the error.
    }

    return indices; 

}

public static void main(String[] args) {
    System.out.println(Arrays.toString(allIndices(new int[]{3, 8, 1, 8, 8, 4}, 0, 8, 0)));
}

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 cannot see your solution to my problem, hence reopened the doubt. Can you please mention the solution again?

have you opened the our chat?

please check our chat or you can check the solution at https://ide.codingblocks.com/s/184856 . the problem was in the else part.
if (arr[si] == data)
indices = allIndices(arr, si + 1, data, count + 1);
else
indices = allIndices(arr, si + 1, data, count);
you have to write "indices = " in else part as allindices is returning something that you should catch