Not a bad intro. Shorter than other videos that cover more details.
@tmzpanda4 жыл бұрын
3:40 non-duplicate 5:35 HashSet vs TreeSet
@stuff12hey14 жыл бұрын
dude are you getting the 3090 Nvidia card?!?!
@samithakulatilaka5 жыл бұрын
Clean and simple explanation.
@DaDavid156 жыл бұрын
I think also LinkedHashSet orders elements. great video very helpful.
@rahuldubey87276 жыл бұрын
Its only maitain the order of insertion..not the order
@NZEDPlays2 жыл бұрын
Thank you for this video. Helped me a lot!!
@Girish_theTechieGuy2 жыл бұрын
Hi Navin, What I have seen in practice is that BOTH HashSet and TreeSet do not show the elements in order. It is also shown in your video. Please correct your future videos on that.
@smeeangle6 жыл бұрын
Very helpful
@Mary-oz6xv3 жыл бұрын
Thank you so much!
@jeanduclos9263 Жыл бұрын
Thanks'
@mohammedviso22697 жыл бұрын
Nice intro
@nashikkarrecipe2 жыл бұрын
And how we will get the elements in descending order
@samiahmad33556 жыл бұрын
thx
@ravishankar63137 жыл бұрын
what should we use if we want to return type in set,or arryList or in general collection
@code-aman81613 жыл бұрын
this was not the sequence, If we will use Linkedhashset at the place of treehashset then we can get the same sequence which we have entered and if we want the records in ascending order then we should use treeset. correct me of I am wrong. Thanks 🙏
@AlineSelle6 жыл бұрын
Great!
@PriyankaSharma-dy8dg6 жыл бұрын
Can we use basic for loop here or it always has to be enhanced one? Please reply sir
@rahuldubey87276 жыл бұрын
Yes
@puttarajkoliwad5 жыл бұрын
How?
@buzzikea5 жыл бұрын
@@puttarajkoliwad you can not, if you want to use regular for loop you need to create Iterator. Iterator iterator = set.iterator(); for (int i = 0; i < set.size() ; i++) { System.out.println(iterator.next()); } OR while (iterator.hasNext()) { System.out.println(iterator.next()); }
Only Collections implementing the List interface allow index based adding of elements via the add(int index, E element) method. To your question, since HashSet is an implementation of Set, it can only add on additional elements to the end of its set. Another point to mention is the internal data storage structure behind HashSet is a Map, guaranteeing uniqueness of its elements via non repeating Keys.
@anishkumark.a.19885 жыл бұрын
How iterator internally works for Set and list ? difference between both internal working.?
@anishkumark.a.19885 жыл бұрын
someone is asked this question into interview room can you please ans me for the same.
@haykmkrtchyan70935 жыл бұрын
Anish kumar k.a. Have you found the answer?
@anishkumark.a.19885 жыл бұрын
@@haykmkrtchyan7093 not yet
@haykmkrtchyan70935 жыл бұрын
@@anishkumark.a.1988 I think for both cases it works the same. Why? Let me explain. As we know Iterator purpose is to iterate over elements. And it has 3 methods as I rememeber: next(), hasNext(), remove(). Ok now the question "how it works internally"? If I'm right, it starts to iterate from the first element and every time we check in a while loop "if it has next element, than iterate". But the question "How iterator internally works for Set and list", I think for both cases iterator works same. + for List we can also use ListIterator, which is for List Interface and its childs. It provides us some new methods and as I remember we can iterate in reverse order too. But the ListIterator you can't use in anywhere else. So my answer is: For both cases list and set, iterator works the same.
@anishkumark.a.19885 жыл бұрын
@@haykmkrtchyan7093 yaa but if you check the internal implementation of set and list for iterator both implementation is bit different.
@chicagobearssingh1956 жыл бұрын
what is that for loop called?
@shubhamshinde43286 жыл бұрын
Enhanced For loop
@karltherock83724 жыл бұрын
or ForEach loop
@divyeshakabari3 жыл бұрын
package Ass5; import java.util.HashSet; import java.util.Set; public class Setexample { public static void main(String [] args) { Set e1=new HashSet(); Event e2=new Event(); e2.setEventid(1); e2.setEventname("tornedo"); e1.add(e2); Event e3= new Event(); e3.setEventid(1); e3.setEventname("tornedo"); e1.add(e3); for(Event e4 : e1) { System.out.println(e4.getEventid()); System.out.println(e4.getEventname()); } } } This is my setexample code while running this code i am not getting proper output as set has its own functionality that it should contain unique value but while running this code i am getting duplicate value as well so what is the solution for this .
@divyeshakabari3 жыл бұрын
1 tornedo 1 tornedo this is my sample output for this code.