About 16,600,000 results
Open links in new tab
  1. How do I declare and initialize an array in Java? - Stack Overflow

    Jul 29, 2009 · You can also create arrays with the values already there, such as. int[] name = {1, 2, 3, 4, 5}; which not only creates the empty space but fills it with those values. Java can tell …

  2. Arrays in Java - GeeksforGeeks

    Mar 28, 2025 · In Java, Jagged array is an array of arrays such that member arrays can be of different sizes, i.e., we can create a 2-D array but with a variable number of columns in each …

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

    Apr 14, 2025 · We first need to declare the size of an array because the size of the array is fixed in Java. In an array, we can store elements of different data types like integer, string, character …

  4. How to increase the size of an array in Java? - Stack Overflow

    Instead of using an array, use an implementation of java.util.List such as ArrayList. An ArrayList has an array backend which holds values in a list, but the array size is automatically handles …

  5. Dynamic Array in Java - GeeksforGeeks

    Nov 13, 2024 · Below are the Steps to create dynamic array in Java: Create a Array with some size n which will be the default size of array. True: then create another array with double size. …

  6. How to create Java array with predefined size | LabEx

    In Java programming, understanding how to create arrays with a predefined size is a fundamental skill for developers. This tutorial will guide you through the essential techniques of array …

  7. Java: how do I initialize an array size if it's unknown?

    Apr 3, 2013 · integers = new int[j + 1]; integers[j] = in.nextInt(); . j++; . You should use a List for something like this, not an array. As a general rule of thumb, when you don't know how many …

  8. Java Arrays - W3Schools

    Arrays are used to store multiple values in a single variable, instead of declaring separate variables for each value. To declare an array, define the variable type with square brackets: …

  9. How to Create an Array in JavaArray Declaration Example

    Mar 16, 2023 · In this article, we will provide a step-by-step guide on how to create an array in Java, including how to initialize or create an array. We will also cover some advanced topics …

  10. Initializing Arrays in Java - Baeldung

    Dec 16, 2024 · In this tutorial, we’ll see how to declare an array. Also, we’ll examine the different ways we can initialize an array and the subtle differences between them. A simple and …