java - Random order of a HashSet is always same until Server stopped -


hashset not maintain order of elements.i deployed app jboss server , observing order of hashset. it random.

but had same random order until restarted application server. can explain situation underlying mechanisms?

i digging issue related order of elements of hashset<object>.

some of our servers had correct order maintaining (still it's random) , didn't. after have done restarts, figured out.

the hashset not guarantee order of elements in it, not mean order randomly change. order of elements change when hashes need re-computed, , happens when capacity of underlying hash table needs change.

the specifics of when capacity of hash changes may vary between different implementations, guaranteed if number of elements in hashset divided capacity of hashset exceeds loadfactor, hashset's capacity increase. whenever capacity increases, hash code of elements re-computed , order of elements may change.


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -