Do you need an array? You can do the following with List:
public static void main(String[] args) {
array = new ArrayList<Map.Entry<Integer, Integer>>();
}
private static List<Map.Entry<Integer, Integer>> array;
Alternatively, you can create an instance of a non-generic type and apply it to the generic type:
public static void main(String[] args) {
array = (Map.Entry<Integer, Integer>[])new Map.Entry[1];
}
private static Map.Entry<Integer, Integer>[] array;
However, this will give you warnings and is usually not preferred.
source
share