About 362,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. java - Initialization of an ArrayList in one line - Stack Overflow

    Jun 17, 2009 · I don't understand why we cannot have some thing like List<Integer> = {1, 2, 3, 4, 5} in Java. Create and init a mutable array in one line, as I know Python and Swift could do that.

  3. java - Create ArrayList from array - Stack Overflow

    Oct 1, 2008 · The simplest answer is to do: 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 …

  4. java - What is the Simplest Way to Reverse an ArrayList ... - Stack ...

    May 26, 2012 · What is the simplest way to reverse this ArrayList? ArrayList<Integer> aList = new ArrayList<> (); //Add elements to ArrayList object aList.add ("1"); aList.add ("2 ...

  5. Convert list to array in Java - Stack Overflow

    Update: It is recommended now to use list.toArray(new Foo[0]);, not list.toArray(new Foo[list.size()]);. From JetBrains Intellij Idea inspection: There are two styles to convert a …

  6. java - what is the difference between a list and an arraylist

    Sep 4, 2012 · Vector is another List, much like an ArrayList in that its implementation is based on a dynamic array; it's, however, a relic of the older versions of Java and is guaranteed to be …

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

  8. java - How much data can a List can hold at the maximum

    Sep 22, 2010 · How much data can be added in java.util.List in Java at the maximum? Is there any default size of an ArrayList?

  9. java - How does ArrayList work? - Stack Overflow

    Aug 12, 2010 · 11 ArrayList uses an Array of Object to store the data internally. When you initialize an ArrayList, an array of size 10 (default capacity) is created and an element added to …

  10. Sum all the elements java arraylist - Stack Overflow

    If I had: ArrayList<Double> m = new ArrayList<Double> (); with the double values inside, how should I do to add up all the ArrayList elements? public double incassoMargherita () { dou...