About 390,000 results
Open links in new tab
  1. How to make a new List in Java - Stack Overflow

    May 13, 2009 · In Java 8. To create a non-empty list of fixed size (operations like add, remove, etc., are not supported): List<Integer> list = Arrays.asList(1, 2); // but, list.set(...) is supported …

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

    Jun 17, 2009 · Java 9 has the following method to create an immutable list as documented (or documented as unmodifiable Java 10+): List<String> places = List.of("Buenos Aires", …

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

    Jun 29, 2011 · {{Double-brace initialization}} is known to create classpath clutter and slow down execution. It also requires one line of code per element. Java 9: the static factory method …

  4. java - Create a List of primitive int? - Stack Overflow

    Aug 2, 2013 · Is there a way to create a list of primitive int or any primitives in java. No you can't. You can only create List of reference types, like Integer, String, or your custom type. It seems I …

  5. arrays - Working with a List of Lists in Java - Stack Overflow

    If you do plan on rolling your own framework, I'd also suggest not using List<List<String>> as your implementation - you'd probably be better off implementing CSVDocument and CSVRow …

  6. java - Create ArrayList from array - Stack Overflow

    Oct 1, 2008 · In Java 9, you can use List.of static factory method in order to create a List literal. Something like the following: Something like the following: List<Element> elements = …

  7. java - List.of() or Collections.emptyList() - Stack Overflow

    Appart from the List.of() that behaves like a non null element List, the major difference is that Collections.emptyList() is a better replacement for a list that is used in further processing. For …

  8. java - How to make a new list with a property of an object which is …

    Imagine that I have a list of certain objects: List&lt;Student&gt; And I need to generate another list including the ids of Students in the above list: List&lt;Integer&gt; Avoiding using a loop,...

  9. How can I turn a List of Lists into a List in Java 8?

    Aug 5, 2014 · And a List's Iterator returns items in sequential order. For the Consumer, this code passes in a method reference (Java 8 feature) to the pre-Java 8 method List.addAll to add the …

  10. Java - map a list of objects to a list with values of their property ...

    List<ViewValue> source = newArrayList(new ViewValue(1), new ViewValue(2), new ViewValue(2)); We could make transformation with List class from Javaslang library (on the …

Refresh