Comment by inigyou
16 hours ago
Java can also distinguish a 2/3 object from a 4/6 object using == when they are not value types. It can even distinguish a 2/3 object from a different 2/3 object.
16 hours ago
Java can also distinguish a 2/3 object from a 4/6 object using == when they are not value types. It can even distinguish a 2/3 object from a different 2/3 object.
The difference, as I tried to explain, is that identity comparison does not expose the internal representation. So while you can know that two objects with the same value are different objects, you can't know whether they internally represent the value as 2/3 or 4/6. With value classes, however, the latter can expose information about the provenance of a value.
Would you use a value class if you wanted to represent a fraction?
[dead]