| |

VerySource

 Forgot password?
 Register
Search
View: 765|Reply: 3

A little problem with collections

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-1-4 13:10:01
| Show all posts |Read mode
Use the same data BEAN (an INT, a STRING, did not implement EQUALS () and HASHCODE ()), which implemented the compareTo () method in Comparable, and then added to HASHSET and TREESET respectively, why can be automatically in TREESET Two objects with the same ordering and status cannot be added to the TreeSet collection at the same time, but not in HASHSET.
Reply

Use magic Report

0

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-3-5 20:30:01
| Show all posts
The HashSet, HashTable and the HashMap are based on the HasCode ().
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-4-22 09:00:02
| Show all posts
Yesterday I checked the information, just like Haiyan (the same name as my previous MM, huh) except TREESET, you must implement the data BEAN EQUALS () and HASHCODE () ...
Reply

Use magic Report

0

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-5-2 06:45:01
| Show all posts
:)
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list