About 31,300 results
Open links in new tab
  1. java - Initialization of an ArrayList in one line - Stack Overflow

    Jun 17, 2009 · Usually you should just declare variables by the most general interface that you are going to use (e.g. Iterable, Collection, or List), and initialize them with the specific …

  2. 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 …

  3. 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 …

  4. 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?

  5. ArrayList or List declaration in Java - Stack Overflow

    Sep 7, 2012 · ArrayList<String> list = new ArrayList<>(); By declaring and using generic types you are informing a structure of the kind of objects it will manage and the compiler will be able to …

  6. java - How can I create an Array of ArrayLists? - Stack Overflow

    I am wanting to create an array of arraylist like below: ArrayList<Individual> [] group = new ArrayList<Individual> () [4]; But it's not compiling. How can I do this?

  7. ArrayList of int array in java - Stack Overflow

    May 7, 2012 · System.out.println("Arraylist contains: " + arl.toString()); If you want to access the i element, where i is an index from 0 to the length of the array-1, you can do a :

  8. java - Two dimensional array list - Stack Overflow

    11 A 2d array is simply an array of arrays. The analog for lists is simply a List of List s. ArrayList<ArrayList<String>> myList = new ArrayList<ArrayList<String>>(); I'll admit, it's not a …

  9. Java: How to have an ArrayList as instance variable of an object?

    4 I'm working on a class project to build a little Connect4 game in Java. My current thinking is to have a class of Columns that have as instance variable a few integers (index, max. length, …

  10. java - How to declare and add to a global array list? - Stack Overflow

    Jul 17, 2019 · I have a project on entering an integer value into a global array. I'm using ArrayList and can't seem to figure out how to add values into the array I'm not quite sure how to add the …