About 4,000,000 results
Open links in new tab
  1. java - How to declare an array of different data types - Stack Overflow

    I know that an array in Java is a collection of similar data types, as shown below: int[] x = new int[]{1,2,3}; The above declaration can be read as an Integer array which is a collection of …

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

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

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

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

  6. Arrays in Java - GeeksforGeeks

    Mar 28, 2025 · 1. Array Declaration. 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 …

  7. java - Initializing an array of custom type - Stack Overflow

    Mar 9, 2012 · But in your case, you don't need to worry about using an array and giving it a size, you can use an ArrayList instead, like so: employees.add(new SalariedEmployee(...)); …

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

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

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

  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: In the code above, we declare an uninitialized array of int type. …

  11. Some results have been removed
Refresh