If, during the application work, several times refer to the hashCode() method of the same object with the same condition, it will return the same value. And if you do the same after restarting the application, may this value be different?
// Simple example
public class Test {
public static void main(String args[]) {
Object obj = new Object();
System.out.println(obj.hashCode());
System.out.println(obj.hashCode());
}
}
HashCode() method of any object must meet the requirements listed inspecifications:
If, during the application work, several times refer to the same object, the hashCode method must consistently return the same integer.
This value is not required to remain unchanged when you restart the same application.
Ввійдіть щоб вподобати
Ввійдіть щоб прокоментувати