3 ms·
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 objec
by inigyou 5mo 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.
- scotty79 5mo ago[dead]
- layer8 5mo agoThe 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.
- crummy 5mo agoWould you use a value class if you wanted to represent a fraction?