Intermediate Java Tutorial – 12 – addAll

///Intermediate Java Tutorial – 12 – addAll

Intermediate Java Tutorial – 12 – addAll

FavoriteLoadingAdd to favorites

Website –
GitHub –
Reddit –
Twitter –
Facebook –
LinkedIn –
Instagram –

source

Java468x60
By |2020-11-10T10:28:30+00:00November 10th, 2020|Java Video Tutorials|44 Comments

44 Comments

  1. Miyuki Umeki November 10, 2020 at 10:28 am - Reply

    ima just drop a comment in 2020

  2. Raihanur Rahman November 10, 2020 at 10:28 am - Reply

    who else is surprised there wasnt any bacon…

  3. rameen alikhani November 10, 2020 at 10:28 am - Reply

    in terms of evolution, java among languages is like humans among chimpanzees!

  4. Mandar Autade November 10, 2020 at 10:28 am - Reply

    what if list 2 had same elements as stuff array had….will it be redundant ?

  5. Elias - November 10, 2020 at 10:28 am - Reply

    awesome professor.

  6. Albin wärme November 10, 2020 at 10:28 am - Reply

    Why do you use the Collections.addAll() rather than just using the built in addAll() function in the ArrayList class? Is it for preference or is there any functional difference that I am missing out on?

  7. Anurag November 10, 2020 at 10:28 am - Reply

    Can't we make a list separately, why do we always have to convert arrays to list?

  8. Akama November 10, 2020 at 10:28 am - Reply

    "digg"

  9. TheUltimateProgrammer November 10, 2020 at 10:28 am - Reply

    uhhhhhhhhhhhhhhhhhhhh so many collections methods. Just wanna get to the good stuff

  10. Ralph Blach November 10, 2020 at 10:28 am - Reply

    well the line
    Collections.addAll(list2, list1);
    no longer works in java8. the interface is expecting individual string values., not an array list

    Chip

  11. Devin M November 10, 2020 at 10:28 am - Reply

    What was the point of converting the array stuff to a list here? can the method addAll take in 2 lists as its parameters?

  12. Primo Luce November 10, 2020 at 10:28 am - Reply

    instead of:

    Collections.addAll(list2, stuff);

    I did more simply:

    list2.addAll(list1);

    and gave me the same result,
    but probably Bucky had his reasons to choose the syntax that he choose

  13. Jinhua Chen November 10, 2020 at 10:28 am - Reply

    import java.util.*;

    public class Bucky {
        public static void main(String[] args) {

            String[] stuff = {"apple", "beef", "corn", "ham"};
            List<String> list1 = Arrays.asList(stuff);

            ArrayList<String> list2 = new ArrayList<String>();
            list2.add("youtube");
            list2.add("google");
            list2.add("digg");

            for(String x : list2)
                System.out.printf("%s ", x);

            Collections.addAll(list2, stuff);

            System.out.println();
            for (String x : list2)
                System.out.printf("%s ", x);

        }
    }

  14. PrismHeart November 10, 2020 at 10:28 am - Reply

    lol yeah I was just thinking the same thing.  What's up with list1?!?

  15. Darkwing Dumpling November 10, 2020 at 10:28 am - Reply

    What was the point of list1 lol

  16. igal schwartz November 10, 2020 at 10:28 am - Reply

    what with list1??
    i can add list2 to list1????

  17. Truman Sharp November 10, 2020 at 10:28 am - Reply

    he must really love digg to actually spell it right

  18. Alexander Dingwall November 10, 2020 at 10:28 am - Reply

    I thought it said add Ai… 🙁 i got excited

  19. David San Antonio November 10, 2020 at 10:28 am - Reply

    no bacon?!?!!? =(

  20. Homopathy November 10, 2020 at 10:28 am - Reply

    If you come to the UK, we will give you a knighthood.

  21. Jadhav Yeshwanth November 10, 2020 at 10:28 am - Reply

    No diff b/w list and ArrayList.
    When you define List as:
    List myList = new ArrayList();
    you can only call methods and reference members that belong to List class.

    ArrayList myList = new ArrayList();
    you'll be able to invoke ArrayList specific methods and use ArrayList specific members in addition to those inherited from List.

    When you call a method of a List class, which was overridden in ArrayList, then method from ArrayList will be called not the one in the List.

    That's called polymorphism.

  22. Ayo04Soul November 10, 2020 at 10:28 am - Reply

    Don't know if you are still answering JAVA questions, but I need help , I'm learning and need to print out all items in a haspmap ? Can you help ?

  23. afdsadf 147852369 November 10, 2020 at 10:28 am - Reply

    Just now? 😀

  24. afdsadf 147852369 November 10, 2020 at 10:28 am - Reply

    We don't need frequency, because technically it's faster to type list2.indexOf("digg"); than Collections.frequency(list2, "digg");

  25. McDucky November 10, 2020 at 10:28 am - Reply

    ctrl+space 🙂

  26. Omar Jesus November 10, 2020 at 10:28 am - Reply

    Just Type SYSO

  27. macuser1232 November 10, 2020 at 10:28 am - Reply

    hey guys you don't need to convert the array, stuff, to a list.

  28. Particular Individual November 10, 2020 at 10:28 am - Reply

    digg is gone.

  29. UFTGaming November 10, 2020 at 10:28 am - Reply

    No. This helps us learn it better.

  30. Jai Rathore November 10, 2020 at 10:28 am - Reply

    wth is digg

  31. J R November 10, 2020 at 10:28 am - Reply

    Glad you got your voice back 😀

  32. Codered1218 November 10, 2020 at 10:28 am - Reply

    Haha! 3:33 "digg"in-it! Thumbs up if you got it!

  33. Overkill November 10, 2020 at 10:28 am - Reply

    I'm still following the tutorials! 😀

  34. Nicholos Tyler November 10, 2020 at 10:28 am - Reply

    I like how Bucky is used to C and uses printf even though println is 100% easier in this way ;D

  35. Shaldares November 10, 2020 at 10:28 am - Reply

    @Entezio Good job, someone had to dislike it JUST because you said that. (P.S, no, it wasn't me. I think Bucky is awesome.)

  36. DazKins November 10, 2020 at 10:28 am - Reply

    condolences to every one woh lost loved ones in 9/11. 10th anniversary

  37. Suman Palisetty November 10, 2020 at 10:28 am - Reply

    Hey bucky I have a small doubt here,

    in Collections.addall(list2, stuff)

    instead of it, it should have been

    Collections.addall(list2, list1)

    please don't mind, I have started learning Java since 2 days only. Am I wrong, if so please give me a bit of explanation. Thank You.

  38. blake rosenberg November 10, 2020 at 10:28 am - Reply

    You should make an iso of all your videos on java (or one iso for each language :P) and release them on your site or something 😛 cool idea…

  39. Mladen Uzelac November 10, 2020 at 10:28 am - Reply

    Where is bacon? 😀

  40. estario November 10, 2020 at 10:28 am - Reply

    @gatoo23 he's done it before but i guess he wanted to show that there was a different way to it( the longer way)

  41. gatoo23 November 10, 2020 at 10:28 am - Reply

    instead of Collections.addAll(list2,stuff); shorter is the way:
    list2.addAll(list1);

  42. Lars Luscuere November 10, 2020 at 10:28 am - Reply

    @treizzy Yeah, list 1 isn't used. You basically can just remove that line and the program still works.

    The reason that Collections.add(list2, list1) doesn't work is just that it can't take a list as an arguement, but it can take an arryay, there's probably a reason for that.

    I guess that if you had list1 and wanted to use it, you would have to change it into an array first and than add it to it.

  43. 1deividas1 November 10, 2020 at 10:28 am - Reply

    can you randomize the list?

  44. 1deividas1 November 10, 2020 at 10:28 am - Reply

    ikr

Leave A Comment

*