About 1,670,000 results
Open links in new tab
  1. How do I declare and initialize an array in Java?

    Jul 29, 2009 · There are several ways to declare and int array: int[] i = new int[capacity]; int[] i = new int[] {value1, value2, value3, etc}; int[] i = {value1, value2, value3, etc}; where in all of …

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

  3. How to Declare and Initialize an Array in Java - Stack Abuse

    Sep 20, 2022 · In this article, we'll go over how to declare and initialize an array in Java, with examples and best practices. We'll cover traditional array declaration and initialization, as well …

  4. Java ArrayHow to Declare and Initialize an Array in Java

    Feb 4, 2022 · We use square brackets [] to declare an array. That is: We have declared a variable called names which will hold an array of strings. If we were to declare a variable for integers …

  5. Java Int Array - Tutorial Kart

    In this tutorial, we will learn how to declare a Java Int Array, how to initialize a Java Int Array, how to access elements of it, etc. How to declare an Integer Array in Java? Following is the syntax …

  6. Java Array – Declare, Create & Initialize An Array In Java

    Apr 1, 2025 · This In-depth Tutorial Explains Various Ways to Declare, Create and Initialize a New Array With Values in Java with the Help of Simple Code Examples.

  7. How to Declare, Initialize and Populate Java int Arrays?

    Feb 11, 2025 · Declaring an int array indicates that we want to create an array of integer values. int [] intArray1; In initialization, an initial memory is allotted to the int array that we declared. int …

  8. How to Declare and Initialize an Array in Java - HowToDoInJava

    Learn to declare and initialize arrays in Java using direct statements, java.util.Arrays class and Stream API with examples.

  9. How to Declare an Array in Java? - GeeksforGeeks

    Feb 28, 2025 · Declaration of an Array in Java is very straightforward. First, we need to specify the data type of the element, followed by square brackets [], and then we need to write the …

  10. Initializing Arrays in Java - Baeldung

    Dec 16, 2024 · We can easily declare an array by specifying its data type followed by square brackets and the array name: int[] numbers; In the code above, we declare an uninitialized …

Refresh