Count the frequency of each element of an array in java. Learn the concept with examples and code snippets.