14.9 Set Interface in Java Collection Framework

  Рет қаралды 164,932

Telusko

Telusko

Күн бұрын

Пікірлер: 37
@jvsnyc
@jvsnyc 4 жыл бұрын
Not a bad intro. Shorter than other videos that cover more details.
@tmzpanda
@tmzpanda 4 жыл бұрын
3:40 non-duplicate 5:35 HashSet vs TreeSet
@stuff12hey1
@stuff12hey1 4 жыл бұрын
dude are you getting the 3090 Nvidia card?!?!
@samithakulatilaka
@samithakulatilaka 5 жыл бұрын
Clean and simple explanation.
@DaDavid15
@DaDavid15 6 жыл бұрын
I think also LinkedHashSet orders elements. great video very helpful.
@rahuldubey8727
@rahuldubey8727 6 жыл бұрын
Its only maitain the order of insertion..not the order
@NZEDPlays
@NZEDPlays 2 жыл бұрын
Thank you for this video. Helped me a lot!!
@Girish_theTechieGuy
@Girish_theTechieGuy 2 жыл бұрын
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.
@smeeangle
@smeeangle 6 жыл бұрын
Very helpful
@Mary-oz6xv
@Mary-oz6xv 3 жыл бұрын
Thank you so much!
@jeanduclos9263
@jeanduclos9263 Жыл бұрын
Thanks'
@mohammedviso2269
@mohammedviso2269 7 жыл бұрын
Nice intro
@nashikkarrecipe
@nashikkarrecipe 2 жыл бұрын
And how we will get the elements in descending order
@samiahmad3355
@samiahmad3355 6 жыл бұрын
thx
@ravishankar6313
@ravishankar6313 7 жыл бұрын
what should we use if we want to return type in set,or arryList or in general collection
@code-aman8161
@code-aman8161 3 жыл бұрын
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 🙏
@AlineSelle
@AlineSelle 6 жыл бұрын
Great!
@PriyankaSharma-dy8dg
@PriyankaSharma-dy8dg 6 жыл бұрын
Can we use basic for loop here or it always has to be enhanced one? Please reply sir
@rahuldubey8727
@rahuldubey8727 6 жыл бұрын
Yes
@puttarajkoliwad
@puttarajkoliwad 5 жыл бұрын
How?
@buzzikea
@buzzikea 5 жыл бұрын
@@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()); }
@nikolapetrovic4415
@nikolapetrovic4415 5 жыл бұрын
@@buzzikea else values.forEach(System.out::println);
@simonmarabi2661
@simonmarabi2661 2 жыл бұрын
intro song?
@SaiKiran-dq6xu
@SaiKiran-dq6xu 4 жыл бұрын
Can we add a value on index basis using hashset
@clublulu399
@clublulu399 4 жыл бұрын
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.1988
@anishkumark.a.1988 5 жыл бұрын
How iterator internally works for Set and list ? difference between both internal working.?
@anishkumark.a.1988
@anishkumark.a.1988 5 жыл бұрын
someone is asked this question into interview room can you please ans me for the same.
@haykmkrtchyan7093
@haykmkrtchyan7093 5 жыл бұрын
Anish kumar k.a. Have you found the answer?
@anishkumark.a.1988
@anishkumark.a.1988 5 жыл бұрын
@@haykmkrtchyan7093 not yet
@haykmkrtchyan7093
@haykmkrtchyan7093 5 жыл бұрын
@@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.1988
@anishkumark.a.1988 5 жыл бұрын
@@haykmkrtchyan7093 yaa but if you check the internal implementation of set and list for iterator both implementation is bit different.
@chicagobearssingh195
@chicagobearssingh195 6 жыл бұрын
what is that for loop called?
@shubhamshinde4328
@shubhamshinde4328 6 жыл бұрын
Enhanced For loop
@karltherock8372
@karltherock8372 4 жыл бұрын
or ForEach loop
@divyeshakabari
@divyeshakabari 3 жыл бұрын
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 .
@divyeshakabari
@divyeshakabari 3 жыл бұрын
1 tornedo 1 tornedo this is my sample output for this code.
14.10 Map Interface in Java Collection Framework
10:01
Telusko
Рет қаралды 254 М.
Set and HashSet in Java - Full Tutorial
20:43
Coding with John
Рет қаралды 233 М.
Twin Telepathy Challenge!
00:23
Stokes Twins
Рет қаралды 121 МЛН
Из какого города смотришь? 😃
00:34
МЯТНАЯ ФАНТА
Рет қаралды 2,6 МЛН
Don't underestimate anyone
00:47
奇軒Tricking
Рет қаралды 21 МЛН
SIZE DOESN’T MATTER @benjaminjiujitsu
00:46
Natan por Aí
Рет қаралды 3,8 МЛН
Java Collections Explained (with examples)
10:39
Visual Computer Science
Рет қаралды 95 М.
#95 Comparator vs Comparable in Java
15:43
Telusko
Рет қаралды 206 М.
#93 Set in Java
7:08
Telusko
Рет қаралды 75 М.
Learn JSON in 10 Minutes
12:00
Web Dev Simplified
Рет қаралды 3,2 МЛН
LinkedList vs ArrayList in Java Tutorial - Which Should You Use?
11:43
Coding with John
Рет қаралды 608 М.
Generics In Java - Full Simple Tutorial
17:34
Coding with John
Рет қаралды 1,1 МЛН
Generics in Java
14:26
Telusko
Рет қаралды 516 М.
Twin Telepathy Challenge!
00:23
Stokes Twins
Рет қаралды 121 МЛН