I am new to Java, I have a question about the hashcode for Java objects:
public class HelloWorld
{
String name;
int age;
}
will different objects with same value for the attributes have same hashCode?
HelloWorld hello1 = new HelloWorld();
hello1.name = "hello";
hello1.age = 20;
HelloWorld hello2 = new HelloWorld();
hello2.name = "hello";
hello2.age = 20;
will hello1
and hello2
have same hashCode?
And also, is it possible that objects with different value for the attributes have the same hashCode?