4 ms·
Overall an excellent article, but its worth mentioning that as I understand it, String's hashCode() method pre-1.3 or 1.2 (forgot exactly which version they swi
by jcdavis 14y ago
Overall an excellent article, but its worth mentioning that as I understand it, String's hashCode() method pre-1.3 or 1.2 (forgot exactly which version they switched over) used a different function, so it can indeed change (as the hashCode() contract allows)
- jbooth 14y agoIt could change, but Object.hashCode(), if not overridden, is operating on the most basic type of Object with zero data members. So they pretty much have to go to the memory address for the hashing functionality, since there's no other information to hash off of. Unless they wanted to just "return 0" for every single one which would be pretty dumb.