I have a following program where I have a hashmap. The keys of the hashmap are simple integers and the values are integer arrays. The program is as follows:
Map<String , int []> myMap = new HashMap<String , int []>();
myMap.put("EvenNumbers", new int[]{2,4,6,8,10,12,14,16,18,20});
myMap.put("OddNumbers", new int[]{1,3,5,7,9,11,13,15,17,19});
myMap.put("DivisibleByThree", new int[]{3,6,9,12,15,18});
myMap.put("DivisibleByFive", new int[]{5,10,15,20});
int[] array = new int[]{1,3,5,7,9,11,13,15,17,19};
System.out.println(myMap.containsKey("EvenNumbers"));
System.out.println(myMap.containsKey("OddNumbers"));
//The following two lines produce a false output. Why ?
System.out.println(myMap.containsValue(new int[]{5,20,15,20} ));
System.out.println(myMap.containsValue(array));
while the following code produces a true value
HashMap newmap = new HashMap();
// populate hash map
newmap.put(1, "tutorials");
newmap.put(2, "point");
newmap.put(3, "is best");
// check existence of value 'point'
System.out.println("Check if value 'point' exists: " +
newmap.containsValue("point"));
Why is this so ? Where have I gone wrong? what is the caoncept that I am missing? I feel that I am doing the same thing in both the cases. I am new to the java environment , hence the confusion. Please help me clear the concepts.