Opening Hours :7AM to 9PM
import java.util.HashMap; public class FrequencyCounter { public static void main(String[] args) { int[] array = {1, 2, 3, 2, 3, 1, 3}; HashMap<Integer, Integer> frequencyMap = new HashMap<>(); // count the frequency of each element in the array for (int i : array) { if (frequencyMap.containsKey(i)) { frequencyMap.put(i, frequencyMap.get(i) + 1); } else { frequencyMap.put(i, 1); } } // print out the frequency of each element for (int key : frequencyMap.keySet()) { System.out.println("Element " + key + " occurs " + frequencyMap.get(key) + " times."); } } }In this example, the program initializes an integer array with the values {1, 2, 3, 2, 3, 1, 3} and creates an empty HashMap called frequencyMap. The for loop iterates over the elements of the array and checks if each element is already a key in the HashMap. If it is, the program increases the value associated with that key by one. If it isn't, the program adds a new key-value pair to the HashMap with the element as the key and the value 1.