Write a java program or function to count the occurrences of each element in an array. For example, if {12, 9, 12, 9, 10, 9, 10, 11} is the input array, then the count of oc