I learned that all primitives with same value have same `identityHashCode`

so, I wanted get `identityHashCode`

of some primitives.so when I tried with 2 doubles with same value it was giving different `identityHashCode`

I did following:

```
int xInt=5;
int yInt=5;
System.out.println(System.identityHashCode(xInt));//output:1867083167
System.out.println(System.identityHashCode(yInt));//output:1867083167
double double1=5;
double double2=5;
System.out.println(System.identityHashCode(double1));//output:1915910607
System.out.println(System.identityHashCode(double2));//output:1284720968
```

two ints with same value have same `identityHashCode`

but two doubles with same value have different `identityHashCode`

why is that?

Your code is boxing the primitive values. (The primitive values themselves don't have an identity hash code, as that's only a concept that's relevant for objects.) Your code is equivalent to this:

Now if you compare the references themselves, you'll see that

`xInteger == yInteger`

is true, but`boxedDouble1 == boxedDouble2`

is false... so`identityHashCode`

is representing that relationship accurately.The reason your boxed integer references refer to the same object is that boxed integral types within a particular range are cached:

The range can actually be bigger in practice, and an implementation

couldcache boxed doubles as well, but I haven't seen that happen.