+ 2

Which Collection Class maintains insertion order in Java .

1) ArrayList 2) HashSet 3)LinkedSet 4) PriorityQeue

23rd Sep 2023, 6:19 AM
Sanjay kumar Sahu
5 Antworten
+ 1
1) ArrayList - yes 2) HashSet - no 3) LinkedSet - doesn't exist, but LinkedHashSet - yes 4) PriorityQeue - doesn't exist, PriorityQueue has natural order or by used Comparator
25th Sep 2023, 7:42 AM
zemiak
+ 2
Sanjay kumar Sahu, For future posts please use the programming language in tags, so that the community has a more precice idea what your issue is.
23rd Sep 2023, 6:26 PM
sandra
sandra - avatar
+ 2
Lists in java maintains order in a way values inserted. While Sets ( also PriorityQueue) don't maintain order. So ArrayList maintains order but HashSet, LinkedHashSet, PriorityQueue don't maintains the order of elements..
24th Sep 2023, 3:17 PM
Jayakrishna 🇮🇳
+ 1
4?
23rd Sep 2023, 6:31 AM
Avijit Pal
Avijit Pal - avatar
+ 1
The way you are inserting the data , the same way it will print. Means Insertion order.
23rd Sep 2023, 6:41 AM
Sanjay kumar Sahu