About 16,400,000 results
Open links in new tab
  1. Convert ArrayList<String> to java.util.List - Stack Overflow

    I get an arrayList of orders from a DB query and then iterate through to pull out order numbers which I then put into a arrayList, which I then want to convert to a List to use in cellList. Can someone explain why I can't do this and what the proper method should be?

  2. java - How to cast ArrayList<> from List<> - Stack Overflow

    You can cast List<> to ArrayList<> if you understand what you doing. Java compiler won't block it. But: It's bad practice to casting parent type to child type (or interface to implementation type) without checking. This way better: if (list instanceof ArrayList<Task>) { ArrayList<Task> arraylist = (ArrayList<Task>) list; }

  3. Converting array to list in Java - Stack Overflow

    Java 16 introduces a new method on Stream API called toList (). This handy method returns an unmodifiable List containing the stream elements. So, trying to add a new element to the list will simply lead to UnsupportedOperationException.

  4. Java Program to Convert an Array into a List - GeeksforGeeks

    Dec 24, 2024 · One of the most easy and effective ways to convert an array into a list in Java is by using the Arrays.asList() method. This method provides a fixed-size list backed by the specified array. Explanation: The Arrays.asList() method converts the given array into a list.

  5. Java ArrayList Conversions To Other Collections - Software …

    Apr 1, 2025 · Q #1) How do you convert an ArrayList to an Array in Java? Answer: To convert an ArrayList to an Array in Java, one can use the toArray ( ) method from ArrayList API that converts a given ArrayList to an Array. Q #2) How do you split a string and store it in an ArrayList in Java? Answer: The string is split using a split function. This method ...

  6. Converting Between an Array and a List in Java - Baeldung

    Apr 4, 2025 · How to Convert between an Array and a List Using plain Java, Guava or Apache Commons Collections.

  7. Conversion of Array To ArrayList in Java - GeeksforGeeks

    Oct 26, 2021 · Following methods can be used for converting Array To ArrayList: Method 1: Using Arrays.asList() method . Syntax: public static List asList(T... a) // Returns a fixed-size List as of size of given array. // Element Type of List is of same as type of array element type.

  8. Converting array to list in Java - EnableGeek

    We will examine many methods for converting Java arrays to lists in this comprehensive article, encompassing numerous cases and factors. The basic ideas of lists and arrays will be covered first, and then each conversion method included in …

  9. 5 ways to convert Array to List in java - Cloudhadoop

    Dec 31, 2023 · In this article, You will learn 5 ways to convert an array of strings numbers to list or ArrayList or LinkedList with for loop, java7/8/9 and guava library

  10. Convert an Array to a List in Java - Techie Delight

    Apr 2, 2024 · This post will discuss how to convert an array to a list using plain Java, Guava, and Apache Commons Collections. There are two general-purpose list implementations in Java — ArrayList and LinkedList. This post will use ArrayList, which offers constant-time positional access and is just plain fast. 1. Naive solution

  11. Some results have been removed
Refresh