About 12,700,000 results
Open links in new tab
  1. How to make an array of arrays in Java - Stack Overflow

    Jul 23, 2017 · String[][] arrays = { array1, array2, array3, array4, array5 }; or. String[][] arrays = new String[][] { array1, array2, array3, array4, array5 }; (The latter syntax can be used in …

  2. Array of Arrays in Java - Examples - Tutorial Kart

    To initialize an array of arrays, you can use new keyword with the size specified for the number of arrays inside the outer array. Copy datatype[][] arrayName = new datatype[size][];

  3. How do I declare and initialize an array in Java?

    Jul 29, 2009 · For creating arrays of class Objects you can use the java.util.ArrayList. to define an array: public ArrayList<ClassName> arrayName; arrayName = new ArrayList<ClassName>(); …

  4. How to initialize all the elements of an array to any specific value …

    Using Java 8, you can simply use ncopies of Collections class: Object[] arrays = Collections.nCopies(size, object).stream().toArray(); In your case it will be: Integer[] arrays = …

  5. How to Initialize an Array in Java? - GeeksforGeeks

    Apr 14, 2025 · In this article, we will discuss different ways to declare and initialize an array in Java. Understanding how to declare an array in Java is very important. In Java, an array is …

  6. Initializing Arrays in Java - Baeldung

    Dec 16, 2024 · In this article, we explored different ways of initializing arrays in Java. Also, we learned how to declare and allocate memory to arrays of any type, including one-dimensional …

  7. How to Create Array of Arrays in Java - Delft Stack

    Feb 12, 2024 · Create an Array of Arrays in Java by Direct Initialization. Direct initialization during declaration is one of the simplest ways to create a 2D array in Java. This method allows …

  8. How to make an array of arrays in Java - JanBask Training

    Apr 18, 2025 · Here's how you can create and use one: 1. Declaration and Initialization. You can declare and initialize a 2D array in a couple of ways: int[][] matrix = new int[3][4]; // 3 rows and …

  9. Arrays in Java - GeeksforGeeks

    Mar 28, 2025 · To declare an array in Java, use the following syntax: type [] arrayName; type: The data type of the array elements (e.g., int, String). arrayName: The name of the array. Note: …

  10. How do I declare and initialize an array in Java?

    4 days ago · Declaring and initializing an array in Java is a fundamental concept, and there are multiple ways to do it depending on your needs—whether you know the values beforehand or …

Refresh