About 938,000 results
Open links in new tab
  1. java - How to declare an ArrayList with values? - Stack Overflow

    ArrayList or List declaration in Java has questioned and answered how to declare an empty ArrayList but how do I declare an ArrayList with values? I've tried the following but it returns a …

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

    Jun 17, 2009 · ArrayList<String> list = new ArrayList<String>() {{ add("A"); add("B"); add("C"); }}; However, I'm not too fond of that method because what you end up with is a subclass of …

  3. ArrayList or List declaration in Java - Stack Overflow

    Sep 7, 2012 · The first declaration has to be an ArrayList, the second can be easily changed to another List type. As such, the second is preferred as it make it clear you don't require a …

  4. java - ArrayList declaration - Stack Overflow

    Closed 13 years ago. Possible Duplicate: ArrayList declaration Java In Java, why is an ArrayList often declared using a List?

  5. java - Initial size for the ArrayList - Stack Overflow

    Jan 17, 2012 · I faced with the similar issue, and just knowing the arrayList is a resizable-array implementation of the List interface, I also expect you can add element to any point, but at …

  6. java - How to declare an ArrayList? - Stack Overflow

    Jun 12, 2012 · ArrayList<String> al = new ArrayList<String>(); Which one of these two should I use and what is the difference between them? I know that the actual methods called are …

  7. arrays - Java ArrayList for integers - Stack Overflow

    Jan 20, 2013 · With your declaration JVM will create a ArrayList of integer arrays i.e each entry in arraylist correspond to an integer array hence your add function should pass a integer array as …

  8. How to create an 2D ArrayList in java? - Stack Overflow

    Jun 6, 2013 · Oh and you declare 2D ArrayList of String in the first part of your question. Is that correct that you need to put String in your inner ArrayList?

  9. What are the List or ArrayList declaration differences in Java?

    Jan 15, 2012 · ArrayList<String> list = new ArrayList<>(); In the above, you're declaring a variable of the concrete class ArrayList which will contain String elements, and instantiate it with the …

  10. Initializing List in constructor or field declaration

    Nov 20, 2015 · I was wondering whether there is a difference in initializing objects like ArrayList&lt;> and stuff in field declaration or constructor. Is there a difference in memory …