For this Question: You are given an array of integers called nums. Find the even number with the highest frequency in the array. If there are multiple even numbers with the same highest frequency, return the smallest one. If there are no even numbers in the array, return -1.The first line contains an integer denoting the length of the array "nums".
The following line contains the space- separated integers of the array "nums".

<b>Constraints:</b>
1 &le; nums. length &le; 2000
0 &le; nums[i] &le; 10<sup>5</sup>Return the most frequent even element. If there are multiple even numbers with the same highest frequency, return the smallest one.Sample Input:
7
0 1 2 2 4 4 1

Sample output:
2

<b>Explanation</b>
The even elements are 0, 2, and 4. Of these, 2 and 4 appear the most.
We return the smallest one, which is 2., I have written this Solution Code: import java.util.*;
class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
        }
        int result = mostFrequentEven(nums);
        System.out.println(result);
    }

    public static int mostFrequentEven(int[] nums) {
        HashMap<Integer, Integer> hap = new HashMap<>();
        int n = nums.length;
        for (int i = 0; i < n; i++) {
            if (nums[i] % 2 == 0)
                hap.put(nums[i], hap.getOrDefault(nums[i], 0) + 1);
        }
        int maxVal = -1;
        int maxFreq = -1;
        for (int j = 0; j < n; j++) {
            if (nums[j] % 2 == 0) {
                if (hap.get(nums[j]) > maxFreq) {
                    maxVal = nums[j];
                    maxFreq = hap.get(nums[j]);
                } else if (hap.get(nums[j]) == maxFreq) {
                    maxVal = Math.min(maxVal, nums[j]);
                }
            }
        }
        return maxVal;
    }
}
, In this Programming Language: Java, Now tell me if this Code is compilable or not?