#22 - What is HashSet in Collection Framework || Important features of HashSet in Java

  Рет қаралды 17,271

Naveen AutomationLabs

Naveen AutomationLabs

Күн бұрын

Пікірлер: 10
@aviet90
@aviet90 4 жыл бұрын
Thanks Naveen for the explanation. If somebody is wondering why the hash set displays the integers in sorted order then that's because hash set uses hash map internally and hash map stores the elements in a hash table. Since we are adding integers it uses integers hash code which returns an integer. So if you add integers they are added as per sorted order. However if you try adding double values then you would see a rather different output as the hash code computation here is slightly different. Set st = new HashSet(); st.add(2.4); st.add(1.4); st.add(3.4); st.add(4.4); st.add(5.4); st.add(6.4); st.add(7.4); st.add(8.4); for (Double i : st) { System.out.println(i);} Output:- 2.4 1.4 6.4 7.4 3.4 4.4 8.4 5.4
@rukmanibabu897
@rukmanibabu897 4 жыл бұрын
Thanks you . All video well explained. i have switched job after watching u r learning video .
@naveenautomationlabs
@naveenautomationlabs 4 жыл бұрын
All the best :)
@shaiksuleman3191
@shaiksuleman3191 4 жыл бұрын
Hi Can you please make videos for front tools using java/jsp .May be it will help u so many resource to participate in events occurring in company so that there is no dependency on other teams
@prikshitverma3885
@prikshitverma3885 4 жыл бұрын
Thank you
@tapaskhandai
@tapaskhandai 2 жыл бұрын
When i add like this s.addAll(Arrays.asList(new int[] {3,5,6})); i am getting the below error: The method addAll(Collection
@maverick3867
@maverick3867 5 ай бұрын
try new Integer[] instead of new int[] as Collection stores objects and not primitives
@sportsinspires6843
@sportsinspires6843 3 жыл бұрын
In ur previous java collection series u taught us that hashset directly extends set interface and tree set extends sorted set and now I am confused between these two videos
@naveenautomationlabs
@naveenautomationlabs 3 жыл бұрын
It's an advanced series. Refer the latest one
@sportsinspires6843
@sportsinspires6843 3 жыл бұрын
@@naveenautomationlabs in latest one also... Hashset directly implementing set interface and tree set implementing sorted set
#23 - What is #EnumSet in Java Collection Framework?
17:06
Naveen AutomationLabs
Рет қаралды 15 М.
To Brawl AND BEYOND!
00:51
Brawl Stars
Рет қаралды 17 МЛН
#15 - Top 20 HashMap Interview Questions in Java || By Naveen AutomationLabs
27:35
#8 - What is HashMap? How to iterate HashMap?
19:57
Naveen AutomationLabs
Рет қаралды 61 М.
Overview of Collection framework || Java Collections Part 1
24:00
Naveen AutomationLabs
Рет қаралды 248 М.
#9 - How to compare two #HashMaps in Java - By Key-Value, By Value and By Keys
17:18
#19 - LinkedList various features and methods (Important for Interviews)
28:03
Naveen AutomationLabs
Рет қаралды 17 М.