- I have empty array, - I create 2 variables that contains identical objects, - I put a content of first variable to my array, using .add() method, - I check if my array contains object from second variable or not, object that is identical as object from first variable, I check it using .contains(Object o) method, - Result is false. - Why?
public boolean check() {
    ArrayList<City> citiesList = new ArrayList<City>();
    City city1 = new City("Warsaw");
    City city2 = new City("Warsaw");
    return (citiesList.contains(city2));
- Method check() returns: false. - Objects in both variables (city1, city2) are identical. Why java say its not?