Java, Spring, Microservices, Interview, Coding.
hashCode(){ return 5; } @Override // A very bad implementation of equals // done here for illustrative purpose only public boolean equals(Object obj){ return true; } } Output: size before iteration 1 Newport size after iteration 1 Refer Overriding hashCode() and equals() method in Java to know more