About 2,390,000 results
Open links in new tab
  1. How to Initialize an Array in Java? - GeeksforGeeks

    Apr 14, 2025 · In an array, we can store elements of different data types like integer, string, character, etc. In this article, we will discuss different ways to declare and initialize an array in …

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

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

    Jul 29, 2009 · The third way of initializing is useful when you declare an array first and then initialize it, pass an array as a function argument, or return an array. The explicit type is required.

  4. Java Defining and Initializing Arrays - DataCamp

    There are several ways to initialize an array in Java. You can initialize an array at the time of declaration using curly braces {} with the values separated by commas. In this example, the …

  5. Java Array Declaration – How to Initialize an Array in Java with ...

    Sep 9, 2021 · There are two ways you can declare and initialize an array in Java. The first is with the new keyword, where you have to initialize the values one by one. The second is by putting …

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

    Apr 1, 2025 · In Java, a one-dimensional array is declared in one of the following ways: Here the ‘data_type’ specifies the type of data the array will hold. The ‘data_type’ can be a primitive …

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

    Sep 20, 2022 · In this article, we discovered the different ways and methods you can follow to declare and initialize an array in Java. We've used curly braces {}, the new keyword and for …

  8. Different Ways to Initialize Array in Java

    Oct 10, 2023 · We will learn about different ways to declare and initialize array in Java. An array is declared by using data type, variable_name with bracket [ ] symbol.

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

  10. Arrays in Java - GeeksforGeeks

    Mar 28, 2025 · There are some basic operations we can start with as mentioned below: 1. Array Declaration. To declare an array in Java, use the following syntax: type [] arrayName; type: …

Refresh