About 105,000 results
Open links in new tab
  1. java - What is the difference between List.of and Arrays.asList ...

    Oct 5, 2017 · Let summarize the differences between List.of and Arrays.asList List.of can be best used when data set is less and unchanged, while Arrays.asList can be used best in case of large and …

  2. Converting array to list in Java - Stack Overflow

    How do I convert an array to a list in Java? I used the Arrays.asList() but the behavior (and signature) somehow changed from Java SE 1.4.2 (docs now in archive) to 8 and most snippets I found on t...

  3. java - Arrays.asList () of an array - Stack Overflow

    Jul 28, 2015 · int[] factors = {1, 2, 3}; ArrayList<Integer> f = new ArrayList(Arrays.asList(factors)); System.out.println(f); } } At the println line this prints something like " [ [I@190d11]" which means that …

  4. java - Create ArrayList from array - Stack Overflow

    Oct 1, 2008 · List<Element> list = Arrays.asList(array); This will work fine. But some caveats: The list returned from asList has fixed size. So, if you want to be able to add or remove elements from the …

  5. How to add elements in List when used Arrays.asList ()

    @SotiriosDelimanolis Lists returned by Arrays.asList are backed by the array passed in, and are unmodifiable. From the documentation (emphasis added), "Returns a fixed-size list backed by the …

  6. java - Arrays.asList () not working as it should? - Stack Overflow

    21 Because java arrays are objects and Arrays.asList() treats your int array as a single argument in the varargs list.

  7. java - Initialize List<> with Arrays.asList - Stack Overflow

    Jul 9, 2016 · Since the asList method in Arrays uses variable arguments, and variable arguments expressions are mapped to arrays, you could either pass an inline array as in:

  8. java - Initialization of an ArrayList in one line - Stack Overflow

    Jun 17, 2009 · Note: the list returned by Collections.singletonList() is immutable, while the list returned Arrays.asList() allows calling the set() method. This may break the code in rare cases.

  9. java - Difference between Arrays.asList (array) and new ArrayList ...

    What is the difference between List<Integer> list1 = new ArrayList<Integer>(Arrays.asList(ia)); // Copy List<Integer> list2 = Arrays.asList(ia); , where ia is an array of integers? I came to know that some …

  10. How do I determine whether an array contains a particular value in Java ...

    Jul 15, 2009 · Arrays.asList () -> then calling the contains () method will always work, but a search algorithm is much better since you don't need to create a lightweight list wrapper around the array, …