I am quite new to coding in general and this may be a simple answer. I certainly hope that it is. I am trying to iterate through a HashMap and compare the Key to an outside object of the same type. When I run the method, it is not showing me that the objects match even though their values are the same. The Point class is made up from 2 integers, an x and a y. Here is my code:
for (HashMap.Entry<Point, Character> entry : map.entrySet()) {
Point point = new Point(0,0);
point = entry.getKey();
if(point == outsidePoint){
//insert code here
}
I know that at some time during the iteration that the point object is equal to the outsidePoint object, but it will not run the code inside the if statement.
Any help would be incredibly beneficial.