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
@rukmanibabu8974 жыл бұрын
Thanks you . All video well explained. i have switched job after watching u r learning video .
@naveenautomationlabs4 жыл бұрын
All the best :)
@shaiksuleman31914 жыл бұрын
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
@prikshitverma38854 жыл бұрын
Thank you
@tapaskhandai2 жыл бұрын
When i add like this s.addAll(Arrays.asList(new int[] {3,5,6})); i am getting the below error: The method addAll(Collection
@maverick38675 ай бұрын
try new Integer[] instead of new int[] as Collection stores objects and not primitives
@sportsinspires68433 жыл бұрын
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
@naveenautomationlabs3 жыл бұрын
It's an advanced series. Refer the latest one
@sportsinspires68433 жыл бұрын
@@naveenautomationlabs in latest one also... Hashset directly implementing set interface and tree set implementing sorted set