What are Sets | Collections in Apex | Salesforce Development Tutorials for beginners by Shrey Sharma

Поделиться
HTML-код
  • Опубликовано: 10 дек 2024

Комментарии • 82

  • @venkateshmasanolla4079
    @venkateshmasanolla4079 6 лет назад +16

    public class Hulk
    {
    Public Static void Check(Set s1,Set s2,Set s3)
    {
    s2.retainAll(s1);
    s3.retainAll(s2);
    System.debug(s3);
    }
    }

    • @SalesforceHulk
      @SalesforceHulk  6 лет назад +5

      AMAZING!
      You are the next JUNIOR HULK, Venkatesh. Congratulations !! Reach me out on salesforcehulk@gmail.com to get your JUNIOR HULK t-shirt.

    • @swarandeepsingh4552
      @swarandeepsingh4552 5 лет назад +1

      Best answer it is

    • @swathibelagere5638
      @swathibelagere5638 3 года назад +1

      Hi, could you please provide the calling method to be written in anonymous window for this too

    • @ravitkumarganti3355
      @ravitkumarganti3355 2 года назад

      Can someone explain how to pass these three list values to the method in the anonymous window

  • @chitramenghani9460
    @chitramenghani9460 4 года назад +8

    public class SetChallenge1 {
    public void checking(List l1,List l2,List l3){
    set s= new set();
    s.addall(l2);
    s.retainAll(l1);
    s.retainAll(l3);
    System.debug('Common Elements' + s);
    }
    }

  • @aviyed
    @aviyed 4 года назад +5

    Hey Shrey. I don’t see any video on Map. I believe 50% of usage would be a Map in SF.

  • @abhishekrajawat5042
    @abhishekrajawat5042 3 года назад +6

    @Salesforce Hulk ​ Hello Shrey, Hope you are doing well.
    I'm a beginner in salesforce and watching Apex programming videos and the 'MAP' collection is missing in the playlist.
    Could you please add MAP video to this playlist so we can complete the collection part?
    please add because your teaching way is very learnable for us and this missing since last 2 years
    Thanks

  • @nagaprathyusha18
    @nagaprathyusha18 2 года назад

    Hey...your vedios are really great for beginners like me...i request you to explain flows from beginner to expert level...

  • @indhiramarimuthu2022
    @indhiramarimuthu2022 3 месяца назад

    Can you pls share the Difference b/w clear and remove all

  • @NareshKumar-vj4jj
    @NareshKumar-vj4jj 5 лет назад +1

    is sObject is generic type which will store all types of data right ?, then whey we are using interger, string data type for storing integer and string values ?...Please correct me if i wrong

  • @amitsethi1008
    @amitsethi1008 6 лет назад +1

    In one line declaration of sets in {} what is method ? always add ??

  • @AnandSingh-gv8nr
    @AnandSingh-gv8nr 2 года назад

    Thank you bro 😊

  • @promisemaluleke5690
    @promisemaluleke5690 4 года назад +1

    Thanks so much for this! I needed It.

  • @NareshKumar-vj4jj
    @NareshKumar-vj4jj 5 лет назад

    Hi Hulk, I just started watching your videos it's really awesome...

  • @aashams
    @aashams 6 лет назад +1

    Pls update with new videos....you are doing great....hats off.....

  • @sujathadarna8800
    @sujathadarna8800 5 лет назад

    Hi Shrey.. Could you please make a session on apex triggers.. It would be really really helpful. though there are no. of videos on triggers, i believe your explanation will be perfect, and makes one to understand it in a very clear way.

  • @theprateekmahajan
    @theprateekmahajan 3 года назад

    list l1 = new list {1,4,7,8};
    list l2 = new list {2,5,3,6,4,8,9};
    list l3 = new list {9,5,2,7,4};
    set sn = new set ();
    sn.addall(l3);
    System.debug(sn.retainAll(l1));
    system.debug(sn); //common b/w l3 and l1
    System.debug(sn.retainAll(l2));
    system.debug(sn); //common b/w l3 and l2 also l1
    //Complexity :- O(1)

  • @smmgiants31
    @smmgiants31 2 года назад

    Hey Salesforce hulk i have q question, whenever i try to execute different commands which i have learned from you it keep giving me the error of " Method does not exist or incorrect signature" , then after that it has happened quite a lot now, where i try to add custom feild in account by __c , .ADDALL or .contians . i have tried everything even copying the code which you used in your example. DID'NT WORK!!
    please guide what is the real issue here?

  • @shubhampatil5184
    @shubhampatil5184 6 лет назад +4

    Apex Class With commonElements() method
    public class SetCommonValues {
    public void commonElements(Set s1, Set s2, Set s3){
    Set commonElements = new Set();
    commonElements.addAll(s1);
    commonElements.addAll(s2);
    commonElements.addAll(s3);
    commonElements.retainAll(s1);
    commonElements.retainAll(s2);
    commonElements.retainAll(s3);
    System.debug('Common Elements : ' + commonElements);
    }
    }
    How to call from Anonymous Window
    SetCommonValues s = new SetCommonValues();
    Set s1 = new Set{15,19,20,22,29,65,75};
    Set s2 = new Set{19,22,24,26,45,65,70};
    Set s3 = new Set{2,4,9,18,19,22,65,75};
    s.commonElements(s1,s2,s3);
    Result : 22:56:09:004 USER_DEBUG [15]|DEBUG| Common Elements : {19, 22, 65}

    • @SalesforceHulk
      @SalesforceHulk  6 лет назад

      Great, Shubham. Very neat code but you got a little late, better luck next time though. :) :)

  • @hitesh4194
    @hitesh4194 2 года назад

    public static void SetQuery(List lst1,List lst2, List lst3){
    // To find the list of common elements in three Lists recieved as an argument
    // Ex 1) lst1 = {1,4,7,8} lst2={2,5,3,6,4,8,9} lst3={9,5,2,7,4}
    // Required Output to be List Comm = {4}
    List Comm = new List();
    for (integer i = 0; i

  • @AsifAli-kr7eg
    @AsifAli-kr7eg 6 лет назад

    Nice Sir, I love the way you teach ;

  • @EA-cl9jt
    @EA-cl9jt 2 года назад

    public class Practices {
    public static Set unique(List l1, List l2, List l3){
    Set s = new Set();
    for (Integer i : l1){
    if (l2.contains(i) && l3.contains(i))
    s.add(i);
    }
    return s;
    }
    }

  • @vishalpawar2929
    @vishalpawar2929 6 лет назад

    Hi, will u please demonstrate example of Nested Map, List and Set....

  • @saptarshipaul10
    @saptarshipaul10 5 лет назад

    The method:
    public class Junior_hulk {
    public static Set commonInt(List l1,List l2,List l3)
    {
    set s=new set();
    s.addall(l1);
    s.retainall(l2);
    s.retainall(l3);
    system.debug('ommon set of integers-->'+(s));
    return s;
    }
    }
    Calling the method:
    list l1=new List{1,4,7,8};
    list l2=new List{2,5,3,6,4,8,9};
    list l3=new List{9,5,2,7,4};
    set s_new=new set();
    s_new=Junior_hulk.commonInt(l1,l2,l3);
    system.debug(s_new);

  • @rishichauhan6318
    @rishichauhan6318 4 года назад

    Hi Shrey, Can you please upload more development tutorials.

  • @xJDPTGx
    @xJDPTGx 6 лет назад

    Ok. Here's my best shot at the 1st example:
    List l1 = New List {1,4,7,8};
    List l2 = New List {2,5,3,6,4,8,9};
    List l3 = New List {1,4,7,8};
    Set s2= new Set ();
    s2.addall (l1);
    s2.addall (l2);
    s2.addall (l3);
    System.debug(s2.Contains(4));
    Can you tell me if this is right or give me a hint if it's wrong? I think I need to use ContainsAll but I was having a bit of trouble getting it to work in my personal Dev Org.

    • @developerteam3154
      @developerteam3154 6 лет назад +1

      your code only replies true when u execute it instead use System.debug(s2.Contains(4) )in if statement and then write System.debug(4); inside ua if it'll work

  • @EDHOKATIESEDDAM
    @EDHOKATIESEDDAM 6 лет назад +1

    Eagerly waiting for map video

    • @SalesforceHulk
      @SalesforceHulk  6 лет назад +3

      Coming up next!

    • @snehaarun7861
      @snehaarun7861 3 года назад

      @@SalesforceHulk Please upload Map concept as well . thanks !

  • @iamarma5190
    @iamarma5190 6 лет назад +7

    hey Shrey here is the program ,have a look.
    public class findCommon {
    public static void common(list l1,list l2,list l3)
    {
    set s1=new set(l1);
    set s2=new set(l2);
    set s3=new set(l3);
    s1.retainall(s2);
    s1.retainall(s3);
    System.debug(s1);
    }
    }
    //save the above typed class and open anonymous window for execution (ctrl+e)
    // type the below code in anonymous window and run it.
    list l1=new list{1,4,7};
    list l2=new list{2,5,3,6,4,8,9};
    list l3=new list{9,5,2,7,4};
    findCommon.common(l1,l2,l3);
    we can do same for the 2nd Example :)
    thanks and Regards,
    Amit Jha.

    • @SalesforceHulk
      @SalesforceHulk  6 лет назад

      Correct!

    • @SuperAbhishekrocks
      @SuperAbhishekrocks 5 лет назад

      why you have used this line s1.retainall(s2) and s1.retainall(s3) can you please explain??

  • @EDHOKATIESEDDAM
    @EDHOKATIESEDDAM 6 лет назад

    Please provide challenge solution in next session... and as like before u explained it very clearly 😍

  • @chetandhapkale8546
    @chetandhapkale8546 5 лет назад

    Bhai..when u r launching next videos..we are eagerly waiting..

  • @chandannagar9701
    @chandannagar9701 5 лет назад +1

    Will you be posting more development videos covering topics like triggers, VF, testing and all that?

  • @EA-cl9jt
    @EA-cl9jt 2 года назад

    public class Practices{
    public static Integer unique(List l1, List l2, List l3){
    Integer unique = 0;
    for (Integer i : l1){
    if (l2.contains(i) && l3.contains(i))
    unique = i;
    }
    return unique;
    }
    }

  • @vishalsoni9408
    @vishalsoni9408 6 лет назад

    Hi please make more videos on Salesforce development part

  • @shubhampatil5184
    @shubhampatil5184 6 лет назад

    Shrey, you did not told who was the winner of last Junior Hulk Challenge, that is on List In Apex Video

  • @vishalbaranwal9633
    @vishalbaranwal9633 Год назад

    public class List_Manipulation {

    public void intersection(List l1, List l2, List l3){
    Set s = new Set(l1);
    s.retainAll(l2);
    s.retainAll(l3);
    System.debug(s);
    }

    public void list1(){
    List l1 = new List{1,4,8,7};
    List l2 = new List{2,5,3,6,4,8,9};
    List l3 = new List{9,5,2,7,4};
    intersection(l1, l2, l3);
    }

    public void list2(){
    List l1 = new List{15,19,20,22,29,65,75};
    List l2 = new List{19,22,24,26,45,65,70};
    List l3 = new List{2,4,9,18,19,22,65,75};
    intersection(l1, l2, l3);
    }
    }

  • @gauravsahu4173
    @gauravsahu4173 6 лет назад

    sir, could you please help for admin exam.

  • @xJDPTGx
    @xJDPTGx 6 лет назад

    Should I put the solution in the comments here for the Junior Hulk thing?

    • @SalesforceHulk
      @SalesforceHulk  6 лет назад +1

      Yes.

    • @xJDPTGx
      @xJDPTGx 6 лет назад +1

      Ok. Here's my best shot at the 1st example.
      List l1 = New List {1,4,7,8};
      List l2 = New List {2,5,3,6,4,8,9};
      List l3 = New List {1,4,7,8};
      Set s2= new Set ();
      s2.addall (l1);
      s2.addall (l2);
      s2.addall (l3);
      System.debug(s2.Contains(4));
      Can you tell me if this is right or give me a hint if it's wrong? I think I need to use ContainsAll but I was having a bit of trouble getting it to work in my personal Dev Org.

    • @joshivivek8964
      @joshivivek8964 3 года назад

      @@xJDPTGx contains method returns a boolean value that is either true or false.. Here in your answer it returns true as s2.contains(4) mean whether value 4 is available in the set or not

  • @pakcheeta7135
    @pakcheeta7135 5 лет назад

    Pls make fast Yar Dev series and also show glimpse I ide

  • @PMarla
    @PMarla 5 лет назад

    public static List findAllCommon(List a, List b, List c)
    {
    List common = new List();
    List finallst = new List();
    for(Integer x:a)
    {
    if(b.Contains(x))
    {
    common.add(x);
    }
    }
    for(Integer y:common)
    {
    if(c.Contains(y))
    {
    finallst.add(y);
    }
    }
    return finallst;
    }
    This method returns the List of elements which are common in the three Lists. Please let me know your views on this so that i can correct myself

  • @xJDPTGx
    @xJDPTGx 6 лет назад +1

    Example #2
    List l1 = New List {15,19,20,22,29,65,75};
    List l2 = New List {19,22,24,26,45,65,70};
    List l3 = New List {2,4,9,18,19,22,65,75};
    Set s2= new Set ();
    s2.addall (l1);
    s2.addall (l2);
    s2.addall (l3);
    System.debug(s2.Contains(19,22,65));

  • @anupamsinghification
    @anupamsinghification 6 лет назад

    Hi, here my solution for the test.
    list l1= new list{1,4,7,8};
    list l2= new list{2,5,3,6,4,8,9};
    list l3 = new list{9,5,2,7,4};
    set s1= new set();
    s1.addAll(l1);
    s1.addAll(l2);
    s1.addall(l3);
    s1.retainAll(l1);
    s1.retainAll(l2);
    s1.retainAll(l3);
    system.debug(s1);

  • @backstagechefs2813
    @backstagechefs2813 5 лет назад

    public List FindingCommonElementFromLists(List l1, List l2, List l3)
    {
    List commonElement=new List();
    for (integer i = 0; i < l1.size(); i++)
    {
    if (l2.Contains(l1[i]) && l3.Contains(l1[i]))
    {
    commonElement.Add(l1[i]);
    }
    }
    return commonElement;
    }

  • @vahinib840
    @vahinib840 4 года назад

    next videos plzz?

  • @abhishektyagi5441
    @abhishektyagi5441 4 года назад

    public class FindCommon {
    public static Set findCommon(List l1,List l2,List l3)
    {
    Set commonSet = new Set();
    List maxList = l1.size() > l2.size() ? (l1.size() > l3.size() ? l1 : l3) : (l2.size() > l3.size() ? l2 : l3);
    for(Integer i=0;i

  • @sasidaransriram6423
    @sasidaransriram6423 5 лет назад

    Can i know when the next video comes in development tutorial series?

  • @highestspirit
    @highestspirit 6 лет назад

    Hi Shrey,
    I am a newbie in Salesforce.
    I tried to solve the question in this chapter, but didn't understand the meaning of O(n).
    Below is my code, its a bit messy. Do let me know if this is correctly done:
    Class:
    public class ShreyTest {
    public static void MyMethod(List L1, List L2, List L3){

    Set s1 = new Set(L1);
    Set s2 = new Set (s1);
    Set s3 = new Set (s1);
    system.debug('First Check');
    system.debug('First list has: ' +s1);
    system.debug('Second list has: ' + L2);
    s1.removeAll(L2);
    system.debug('Elements unique to List 1: ' +s1);
    s3.removeAll(s1);
    system.debug('Elements common to List 1 and 2: ' +s3);
    system.debug('************************');
    Set st1 = new Set(L2);
    Set st2 = new Set (st1);
    Set st3 = new Set (st1);
    system.debug('Second Check');
    system.debug('Second List has: ' +st1);
    system.debug('Third List has: ' +L3);
    st1.removeAll(L3);
    system.debug('Elements unique to List 2: ' +st1);
    st3.removeALL(st1);
    system.debug('Elements common to List 2 and 3: ' +st3);
    system.debug('************************');
    system.debug('3nd loop');
    Set sr1 = new Set(s3);
    Set sr2 = new Set (s3);
    Set sr3 = new Set (st3);
    sr2.removeALL(sr3);
    system.debug(sr2);
    sr1.removeALl(sr2);
    system.debug('Elements unique in all 3 lists: ' +sr1);
    }
    }
    To call this method, in console I write:
    List Lst1 = new List{15,19,20,22,29,65,75};
    List Lst2 = new List {19,22,24,26,45,65,70};
    List Lst3 = new List {2,4,9,18,19,22,65,75};
    ShreyTest.MyMethod(Lst1, Lst2, Lst3);

  • @dipikabisne2249
    @dipikabisne2249 3 года назад

    Hello sir, I want to be a junior Hulk

  • @jatinneelay8674
    @jatinneelay8674 3 года назад

    Map?

  • @luvrajsingh4357
    @luvrajsingh4357 Год назад

    public class Hulk
    {
    Public Static void Check(Set s1,Set s2,Set s3)
    {
    s2.retainAll(s1);
    s3.retainAll(s2);
    System.debug(s3);
    }
    }