14.9 Set Interface in Java Collection Framework

Поділитися
Вставка
  • Опубліковано 7 вер 2024
  • Check out our website: www.telusko.com
    Follow Telusko on Twitter: / navinreddy20
    Follow on Facebook:
    Telusko : / teluskolearnings
    Navin Reddy : / navintelusko
    Follow Navin Reddy on Instagram: / navinreddy20
    Subscribe to our other channel:
    Navin Reddy : / @navinreddy
    Telusko Hindi :
    / @teluskohindi

КОМЕНТАРІ • 37

  • @jvsnyc
    @jvsnyc 4 роки тому +1

    Not a bad intro. Shorter than other videos that cover more details.

  • @tmzpanda
    @tmzpanda 4 роки тому +7

    3:40 non-duplicate
    5:35 HashSet vs TreeSet

    • @stuff12hey1
      @stuff12hey1 4 роки тому

      dude are you getting the 3090 Nvidia card?!?!

  • @samithakulatilaka
    @samithakulatilaka 5 років тому +2

    Clean and simple explanation.

  • @DaDavid15
    @DaDavid15 5 років тому +3

    I think also LinkedHashSet orders elements. great video very helpful.

    • @rahuldubey8727
      @rahuldubey8727 5 років тому +6

      Its only maitain the order of insertion..not the order

  • @NZEDPlays
    @NZEDPlays 2 роки тому

    Thank you for this video. Helped me a lot!!

  • @jeanduclos9263
    @jeanduclos9263 Рік тому

    Thanks'

  • @Mary-oz6xv
    @Mary-oz6xv 3 роки тому

    Thank you so much!

  • @smeeangle
    @smeeangle 6 років тому +1

    Very helpful

  • @mohammedviso2269
    @mohammedviso2269 7 років тому +2

    Nice intro

  • @Girish_theTechieGuy
    @Girish_theTechieGuy Рік тому

    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.

  • @ravishankar6313
    @ravishankar6313 7 років тому

    what should we use if we want to return type in set,or arryList or in general collection

  • @samiahmad3355
    @samiahmad3355 5 років тому

    thx

  • @AlineSelle
    @AlineSelle 6 років тому

    Great!

  • @nashikkarrecipe
    @nashikkarrecipe 2 роки тому

    And how we will get the elements in descending order

  • @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 🙏

  • @simonmarabi2661
    @simonmarabi2661 Рік тому

    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.

  • @PriyankaSharma-dy8dg
    @PriyankaSharma-dy8dg 5 років тому

    Can we use basic for loop here or it always has to be enhanced one?
    Please reply sir

    • @rahuldubey8727
      @rahuldubey8727 5 років тому

      Yes

    • @puttarajkoliwad3289
      @puttarajkoliwad3289 5 років тому

      How?

    • @buzzikea
      @buzzikea 4 роки тому

      @@puttarajkoliwad3289 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 4 роки тому

      @@buzzikea else
      values.forEach(System.out::println);

  • @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 4 роки тому

      Anish kumar k.a. Have you found the answer?

    • @anishkumark.a.1988
      @anishkumark.a.1988 4 роки тому +1

      @@haykmkrtchyan7093 not yet

    • @haykmkrtchyan7093
      @haykmkrtchyan7093 4 роки тому

      @@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 4 роки тому +1

      @@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?

  • @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.