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

    List<String> x = new ArrayList<String>(Arrays.asList("xyz", "abc")); It's a good practice to declare the ArrayList with interface List if you don't have to invoke the specific methods.

  2. Initialize an ArrayList in Java - GeeksforGeeks

    Apr 7, 2025 · Below are the various methods to initialize an ArrayList in Java. 1. Initialization with add () Syntax: Example 1: This example demonstrates how to create an ArrayList using the …

  3. Java ArrayList - W3Schools

    Java ArrayList. The ArrayList class is a resizable array, which can be found in the java.util package. The difference between a built-in array and an ArrayList in Java, is that the size of an …

  4. Directly setting values for an ArrayList in Java - Stack Overflow

    Jan 21, 2011 · Setting a list of values for a Java ArrayList works: Integer[] a = {1,2,3,4,5,6,7,8,9}; ArrayList<Integer> possibleValues2 = new ArrayList<Integer>(Arrays.asList(a)); However, the …

  5. How to Initialize an ArrayList in JavaDeclaration with Values

    Apr 21, 2023 · In this article, you'll learn how to declare and initialize an ArrayList in Java. You'll see the different in-built methods that can be used to add, access, modify, and remove …

  6. How to Declare an ArrayList with Values in Java?

    Feb 1, 2024 · There is a basic way to declare an ArrayList with values is by Adding elements one by one by using the add() method. Syntax: ArrayList<Integer> arrayList = new …

  7. Java: define terms initialization, declaration and assignment

    declaration: whenever you define a new variable with its type. assignment: whenever you change the value of a variable by giving it a new value

  8. ArrayList in Java - GeeksforGeeks

    Mar 12, 2025 · ArrayList is a Java class implemented using the List interface. Java ArrayList, as the name suggests, provides the functionality of a dynamic array where the size is not fixed as …

  9. Java ArrayList – How To Declare, Initialize & Print An ArrayList

    Apr 1, 2025 · This Tutorial Explains How to Declare, Initialize & Print Java ArrayList with Code Examples. You will also learn about 2D Arraylist & Implementation of ArrayList in Java: Java …

  10. How to declare an ArrayList with values? - W3docs

    To declare an ArrayList with values in Java, you can use the Arrays.asList method and pass it an array or a list of values. Here's an example of how you can declare an ArrayList with values …

Refresh