Write a program in Java that initializes an array of non-negative integers and prints a two-column list, described as follows. The first column is a list of the distinct array elements; the second column is the count of the number of occurrences of each element. The list should be sorted on entries in the first column, largest to smallest.

For input array 4 0 4 9 0

the output should be:

N Count

9 1

4 2

0 2

For input array 12 3 12 4 1 1 12 1 7 1 2 3 4 2 3 12

the output should be:

N Count

12 4

7 1

4 2

3 3

2 2

1 4

My code so far-

package lab16; public class Driver { int[] array = {4,0,4,9,0}; private int[] getDistinct(int[] dist){ dist = new int[array.length]; for(int i : dist){ dist[i] = array[i]; for(int j : dist){ if(dist[j] == dist[j+1]){ dist [j] = -1; } } if (dist[i] > 0){ System.out.println(dist[i]); } } return dist; } private void BubbleSort(int[] order){ order = new int[array.length]; boolean flag = true; int temp; while(flag){ flag = false; for(int k : order){ if(order[k] > order[k+1]){ temp = order[k]; order[k] = order[k+1]; order[k+1] = temp; flag = true; } } } } private int findNumberOfOccurances(int[] occ, int counter, int lastItem){ counter = 0; lastItem = array[0]; for(int i : array){ if (array[i] == lastItem){ counter ++; }else{ counter = 1; } } return occ[counter]; } public static void main(String[] args){ } }

Again, any pointers are very much appreciated. I'm a little confused on how I'm supposed to output the correct response. I'm not sure how to store the information I'm obtaining from my loop and print out that stored array?

Thanks!