Intermediate Java Tutorial – 8 – Converting Lists to Arrays

///Intermediate Java Tutorial – 8 – Converting Lists to Arrays

Intermediate Java Tutorial – 8 – Converting Lists to Arrays

FavoriteLoadingAdd to favorites

Facebook –
GitHub –
Google+ –
LinkedIn –
reddit –
Support –
thenewboston –
Twitter –

source

Java468x60
By |2019-12-26T00:43:40+00:00December 26th, 2019|Java Video Tutorials|42 Comments

42 Comments

  1. nischal bhatt December 26, 2019 at 12:43 am - Reply

    buck. i love u man. i really really do

  2. star moh December 26, 2019 at 12:43 am - Reply

    things so far are pretty cool , but how do i keep up with all the methods πŸ™ i don't have a good memory

  3. Lightning theBeast December 26, 2019 at 12:43 am - Reply

    Hmm

  4. Junga December 26, 2019 at 12:43 am - Reply

    bro like why do i even pay my college tuition when i learn everything off of your videos

  5. Celiber December 26, 2019 at 12:43 am - Reply

    πŸ™‚

  6. ε’šε’šθ±† December 26, 2019 at 12:43 am - Reply

    thelist.add(0, "first"); Β can replace .addFirst method.

  7. Tusk TV December 26, 2019 at 12:43 am - Reply

    whats the difference between LinkedList<String> list=new LinkedList<String>();
    and List<String> list=new LinkedList<String>();…….?

  8. Michelangelo Mecozzi December 26, 2019 at 12:43 am - Reply

    Guys you don't actually need to spell it "watermelong"! I tested it and it works with regular watermelon.




    Love you Bucky

  9. The Savvy Monk Studio December 26, 2019 at 12:43 am - Reply

    this would also work

    List<Integer> something = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 13);
    ArrayList moreNumbers = new ArrayList<>();
    for(int c : something){
    moreNumbers.add(c);
    }
    moreNumbers.add(33);
    moreNumbers.add(66);
    moreNumbers.add(88);

    System.out.println(moreNumbers);

  10. Ryan West December 26, 2019 at 12:43 am - Reply

    Hello, If you're having trouble adding the LinkedList<String> not populating properly for you and still showing an error even after importing the java.util.*try adding it manually by adding java.util.LinkedList<String> theList = new java.util.LinkedList<String(Arrays.asList(Stuff));

  11. Daniel K December 26, 2019 at 12:43 am - Reply

    Just a tip. You don't need to convert to a new array. You can loop through a list this way instead!

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

  12. Subh Samal December 26, 2019 at 12:43 am - Reply

    I understood both array to list and list to array conversion. But the problem is: list to array conversion syntax is difficult for me to remember. Any tricks ??

  13. Robson Sousa December 26, 2019 at 12:43 am - Reply

    public static String class8(){

    System.out.print("********************************************************n");
    // Java Intermediate Tutorial Class 8
    System.out.print("Class 8 – Converting Lists to Arrays: " + "ngetModifiers: " + Bucky.class.getModifiers() + "nn");
    // I add a example of every class to learn/remember myself about what the methods called inside these classes do.

    String[] stuff = {" Thank,", " ", "you", " ", "so", " ", "much!", " Great", " tutorial", " "};
    LinkedList<String> thelist = new LinkedList<String>(Arrays.asList(stuff));

    thelist.add(":)");
    thelist.addFirst("Bucky, ");

    stuff = thelist.toArray(new String[thelist.size()]);

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

    return "n";

    }

    public static void main(String[] args) {

    System.out.println(Bucky.class8());
    }

  14. Marlon Constance December 26, 2019 at 12:43 am - Reply

    hi bucky will this program work if i use an array of integers cause i am getting errors phoey

  15. Jason Tesch December 26, 2019 at 12:43 am - Reply
  16. Hurricoaster December 26, 2019 at 12:43 am - Reply

    Feel the power, feel the Bern

  17. BOUAISSA Seddik December 26, 2019 at 12:43 am - Reply

    "pumpkinnf" make sure you spell it compliantly wrong because we don't care. lol that was funny

  18. Eshan Patil December 26, 2019 at 12:43 am - Reply

    We can use enhanced for loop for list also.

  19. Mariano Segura Maag December 26, 2019 at 12:43 am - Reply

    im getting an error on Arrays.asList(); "Arrays cannot be resolved"

  20. guru prasaad December 26, 2019 at 12:43 am - Reply

    need for advanced methods

  21. Delli Kilari December 26, 2019 at 12:43 am - Reply

    But why we need to create again with new String(list.size())) ?

  22. ADaviii December 26, 2019 at 12:43 am - Reply

    I've got a question. Is there any true benefit to using an array instead of a LinkedList? Considering LinkedLists are dynamic and can do everything an array can, what is the purpose of using an array?

  23. Rohan Mital December 26, 2019 at 12:43 am - Reply

    Some important information:

    You do NOT need to use an array to do an advanced for loop. You could just as easily not convert the list to an array and use the list reference instead. In fact, lists should be used pretty much all the time instead of arrays because all that these two constructs do in the first place is store references to objects (that's key!) not the objects themselves. Lists also provide more flexibility at no cost to performance.

    http://stackoverflow.com/questions/716597/array-or-list-in-java-which-is-faster

    In other words, never ever convert to an array. There's absolutely no reason to, it'd be wasted space and more compiling time (minimal as the compiling time hit would be :P)

  24. Simon Mai December 26, 2019 at 12:43 am - Reply

    can this be done with a 2D array also?

  25. net ninja December 26, 2019 at 12:43 am - Reply

    Can anybody explain why to pass "new String[thelist.size()]" to toArray method? and what is the difference if i do "list.toArray(stuff);" vs "stuffs = thelist.toArray(new String[thelist.size()]);"??

  26. Tr4vy December 26, 2019 at 12:43 am - Reply

    I FEEL TEH POWAH I FEEL TEH BURN

  27. Devin Harris December 26, 2019 at 12:43 am - Reply

    You could also do the list.toArray(stuff);

  28. Vikas Sharma December 26, 2019 at 12:43 am - Reply

    " The Thing Bucky is.. "

  29. Kevin w December 26, 2019 at 12:43 am - Reply

    The addFirst("") method was not being recognized for me so I just used the add(0,string)

  30. SomethingToJenga December 26, 2019 at 12:43 am - Reply

    "Okay, now we're going to add 'pumpkin' to the list…"

    thelist.add(pumpikuntakinte);

  31. Andrew spencer December 26, 2019 at 12:43 am - Reply

    Why does he use the printf function rather than print or println?

  32. Maltager December 26, 2019 at 12:43 am - Reply

    Great work! You made sure you spelt most things wrong.

  33. Maltager December 26, 2019 at 12:43 am - Reply

    Was I the only one laughing through the entire video at the way he spelt pumpkin as pumpikinf xD

  34. Kuan Li December 26, 2019 at 12:43 am - Reply

    I took extra care in misspelling correctly πŸ˜‰

  35. Marko Perica December 26, 2019 at 12:43 am - Reply

    Fell the power, feel the burn! xD

  36. PrasinoXorton December 26, 2019 at 12:43 am - Reply

    Got a question.
    Why if I declare the list like:
    List 'String' thelist = new .., or Collection 'String' thelist = new … instead of LinkedList 'String' thelist = new …
    I cannot use the addFirst() Method? In a previous tutorial you said to declare it the highest level due to Polymorphism( or sthng like that). Why declaring like this doesn't treat the thelist item like a LinkedList?

  37. zerocool 18 December 26, 2019 at 12:43 am - Reply

    i freaking love u , thank u thank u thanks u

  38. Madhav Pai December 26, 2019 at 12:43 am - Reply

    lol..melons..
    .
    .
    .
    if you know what i mean..

  39. mohan kumar December 26, 2019 at 12:43 am - Reply

    hey bucky wat is the difference of adding arrays to list and converting array to list …… @thenewboston

  40. mohan kumar December 26, 2019 at 12:43 am - Reply

    if u r using array object its possible ……… but u cannot do so using linked list object cause linked list are not indexed instead it uses pointer for pointing next and previous element …………….

  41. appleskitest1 December 26, 2019 at 12:43 am - Reply

    watermelong…

  42. Kevin Pek December 26, 2019 at 12:43 am - Reply

    array list is indexed therefore stuff[1] is valid … as the name says ARRAY LIST … the advantage is a dynamically sized array

Leave A Comment

*