I'm a professional writer and Business Development with more than 10 years of experience. I have worked for a lot of businesses and can share sample works with you upon request. Chat me up and let's get started.
Here are a couple of similarities between ArrayList and HashSet in Java:
1) Both ArrayList and HashSet have not synchronized collection classes and not meant to be used in multi-threading and concurrent environments. You can make ArrayList and HashSet synchronized by using Collections.synchroinzedCollection() just like we make ArrayList and HashSet read-only another day.
2) The ArrayList and the HashSet both can be traversed using Iterator. This is, in fact, a preferred way if you want to perform an operation on all elements.
3) An iterator of ArrayList and HashSet both are fail-fast, i.e. they will throw ConcurrentModificationException if ArrayList or HashSet is modified structurally once Iterator has been created.
Liked By
Write Answer
What is Similarities between ArrayList and HashSet ?
Join MindStick Community
You have need login or register for voting of answers or question.
Shrikant Mishra
12-Mar-2020Here are a couple of similarities between ArrayList and HashSet in Java:
1) Both ArrayList and HashSet have not synchronized collection classes and not meant to be used in multi-threading and concurrent environments. You can make ArrayList and HashSet synchronized by using Collections.synchroinzedCollection() just like we make ArrayList and HashSet read-only another day.
2) The ArrayList and the HashSet both can be traversed using Iterator. This is, in fact, a preferred way if you want to perform an operation on all elements.
3) An iterator of ArrayList and HashSet both are fail-fast, i.e. they will throw ConcurrentModificationException if ArrayList or HashSet is modified structurally once Iterator has been created.