About 19,900,000 results
Open links in new tab
  1. Create an array of ArrayList<String> elements - Stack Overflow

    Dec 29, 2010 · If you really want an ArrayList<String>[] structure, you can simply create a class that extends ArrayList and make an array of that class: And in your implementation: Here is a …

  2. What is the shortest way to initialize List of strings in java?

    Jun 29, 2011 · List<String> list3 = new ArrayList<String>() {{ add("s1"); add("s2"); add("s3"); }}; When it comes to arrays, you could initialize it at the point of declaration like this: String[] arr = …

  3. Initialize an ArrayList in Java - GeeksforGeeks

    Apr 7, 2025 · ArrayList<Type> listName = Stream.of(element1, element2, ..., elementN).collect(Collectors.toCollection(ArrayList::new)); Example: This example …

  4. How to convert a String into an ArrayList? - Stack Overflow

    Sep 8, 2011 · A simpler character based approach would be: ArrayList<String> myList = new ArrayList<String>(); for(Character c :s.toCharArray() ) { myList.add(c.toString()); } But I don't …

  5. Java ArrayList - W3Schools

    Create an ArrayList object called cars that will store strings: import java.util.ArrayList; // import the ArrayList class ArrayList<String> cars = new ArrayList<String>(); // Create an ArrayList object

  6. How to populate a static List (ArrayList, LinkedList) in Java (syntax)

    Apr 1, 2024 · List<String> strings = new ArrayList<>(List.of("Hello", "world")); Prior to Java 9. For Java 8 and older JVMs, I show an older approach down below, but I just learned about this …

  7. How to Create and Manage an ArrayList of String Arrays in Java?

    In Java, you can utilize the ArrayList data structure to store arrays of Strings. An ArrayList provides dynamic resizing, which allows it to grow as needed. This tutorial outlines how to …

  8. Java List of Strings: Creation, Manipulation, and More

    Nov 6, 2023 · Here is a simple example of how to create a list of strings using the ArrayList class: List<String> fruits = new ArrayList<String>(); fruits.add("Apple"); fruits.add("Banana"); …

  9. Convert String array to ArrayList - W3docs

    To convert a String array to an ArrayList in Java, you can use the following steps: import java.util.Arrays; Alternatively, you can use the addAll() method of the ArrayList class to add all …

  10. Java - Create a new array list, add some elements and print

    5 days ago · Java Collection, ArrayList Exercises and solution: Write a Java program to create an array list, add some colors (strings) and print out the collection.

  11. Some results have been removed
Refresh