Hi, well i am unable to understand that why it is mandatory
to have same hashcode, if two objects are same?
Thanks in advance.
Answers were Sorted based on User's Feedback
Answer / nalluri
Hi,
No. Never same hash code to 2 same objects. every object is
having it's own hash code.
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / venkateswara reddy
NO No NO....
Check it once..
If there r two same objects, there must be a diffent
hashcode to them....
U never find same hashcode to any two objects
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / rajshekaran pillai
As the JVM assigns the hashcode to an object value and not
the reference the hashcode for the same object will be same.
the equals() method of the object class uses this hashcode
to evaluate if the objects have same value. therefore
Object o1 = new String("ABC");
Object o2 = "ABC";
/**
* will have the same hashcode
* therefore when we do..
*/
if(o1 == o2){
System.out.println("The object reference is same");
}else if(o1.equals(o2)){
System.out.println("The object has same value");
}
/**
* The output is
* The object has same value
*/
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / prasanna
If two objects are equal then there hashcode must same.
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / nalluri
Hi,
No. Never same hash code to 2 same objects. every object is
having it's own hash code.
| Is This Answer Correct ? | 0 Yes | 0 No |
What is the difference between a method and a function in alice?
class A { public void disp(int a,int b) { System.out.println("hai"); } } class B { public void disp(int a,int b,int c) { System.out.println("hai"); } } above program is overloading or overriding?
Interface A { String test(); } Interface B { int test(); } Create a class AB which must implements both A & B interfaces.
What is constant in programming?
What are the main uses of java?
If there are two notepad opened and working on it . is this a process or thread? computer based Live Example to differentiate between Thread , Process , and Multi tasking ?
What is the use of beaninfo?
what is use of functional interface in java 8?
What is the buffer limit?
How can u create the Object of class Without using "New" opertor?
Hi ,i convert contrller as jSp And presentation as servlet ...will it do? if so what are advantage and idsadvantages
What is “try and catch” in java