I created a class that finds the number of n occurrences for numbers in an Int non sorted Java array. I need to improve it so i do not have to use for loop inside another for. The array can take maximum 99 items. The array can not be sorted. So no sorting allowed by the use cases. Also no imports allowed. You can run the code [here](https://www.tutorialspoint.com/compile_java_online.php). Any help appreciated.

```
    import java.util.Arrays;

    public class Solution {

         public static void main(String args[])  
        {  
            Solution newInstance = new Solution();
           int[] myIntArray = {1,2,6,2,3,3,3,4,5,5};
            newInstance.solution( myIntArray ,1);
        }

        public static int[] solution(int[] data, int n) {

            int newData[] = new int[data.length];
                int indexOfNewData = 0;
                int timesCurrentTempItemFound = 0;

                 System.out.println ("temp array: " + Arrays.toString(data) + "\n");

                for (int k=0; k<data.length; k++) {

                    int currentTempItem = data[k];
                    timesCurrentTempItemFound = 0;

                    for (int i=0; i<data.length; i++) {
                        if (currentTempItem == data[i]) {
                            timesCurrentTempItemFound++;
                        }
                    }

                    if (timesCurrentTempItemFound == n) {

                        boolean itemAlreadyExists = false;

                        for (int index=0; index<data.length; index++) {
                            if (data[k] == newData[index]) {
                                itemAlreadyExists = true;
                            }
                        }

                        if (itemAlreadyExists == false) {
                            newData[indexOfNewData] = data[k];
                            indexOfNewData++;
                        }
                    }
                }

                indexOfNewData = 0;
                for(int i = 0; i<newData.length; i++) {
                    if(newData[i] != 0) {
                        newData[indexOfNewData] = newData[i];
                        indexOfNewData++;
                    }

                }
                int totalItemsInDataArrayWithoutZeros = indexOfNewData;

                int newDataArray[] = new int[totalItemsInDataArrayWithoutZeros];

                for (int i=0; i<totalItemsInDataArrayWithoutZeros; i++) {
                    newDataArray[i] = newData[i];
                }
     System.out.println ("temp array remove zeros: " + Arrays.toString(newDataArray) + "\n");
                return newDataArray;
    }

}

```