🌐
W3Schools
w3schools.com › java › java_arrays.asp
Java Arrays
Java Examples Java Videos Java ... Plan Java Interview Q&A ... Arrays are used to store multiple values in a single variable, instead of declaring separate variables for each value....
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › util › Arrays.html
Arrays (Java Platform SE 8 )
July 21, 2026 - Java™ Platform Standard Ed. 8 ... This class contains various methods for manipulating arrays (such as sorting and searching).
🌐
GeeksforGeeks
geeksforgeeks.org › java › arrays-in-java
Arrays in Java - GeeksforGeeks
An array is a collection of elements of the same data type stored in contiguous memory locations. It allows multiple values to be stored under a single name and accessed using an index.
Published: May 8, 2026
🌐
Runestone Academy
runestone.academy › ns › books › published › apcsareview › ArrayBasics › abasics.html
8.1. Arrays in Java — AP CSA Java Review - Obsolete
An array is consecutive storage for multiple items of the same type. You can store a value in an array using an index (location in the array). You can get a value from an array using an index. An array is like a row of lockers, except that you can’t cram lots of stuff into it.
🌐
Oracle
docs.oracle.com › javase › tutorial › java › nutsandbolts › arrays.html
Arrays (The Java™ Tutorials > Learning the Java Language > Language Basics)
See Java Language Changes for a ... enhancements, and removed or deprecated options for all JDK releases. An array is a container object that holds a fixed number of values of a single type....
🌐
YouTube
youtube.com › watch
Learn Java arrays in 9 minutes! 🍎 - YouTube
#java #javatutorial #javacourse import java.util.Arrays;public class Main { public static void main(String[] args){ // array = a collection of valu...
Published: December 5, 2024
🌐
CodeGym
codegym.cc › java blog › java arrays › java arrays
Java arrays with Examples
April 24, 2025 - An array is a data structure that stores elements of the same type. You can think of it as a set of numbered cells. You can put some data in each cell (one data element per cell).
Find elsewhere
🌐
Reddit
reddit.com › r/javahelp › eli5: what is an array in java
r/javahelp on Reddit: ELI5: What is an Array in Java
February 15, 2017 -

I keep reading over on the Oracle site and I just can't seem to understand it.

Top answer
1 of 4
43
If you imagine a normal variable as a box that can hold one single element, an array is a group of such boxes (under one single name) that each can hold one single element, where all boxes hold the same type of element and where each of the boxes has a unique number: the array index. You need to know how many "boxes" you need in advance - this is the array size that you need to know when declaring your array. "Normal variable": int x = 5; +-------+ int x ----> | 5 | +-------+ "Array": int[] x = new int[5]; +-----+-----+-----+-----+-----+ int x ----> | 0 | 0 | 0 | 0 | 0 | +-----+-----+-----+-----+-----+ Array index 0 1 2 3 4
2 of 4
2
There are already good explanations in other comments, but here is a copypaste of a previous answer of mine in a similar thread: Arrays are data structures of a particular data or object type, that join together several consecutive memory storage locations of that same type conveniently into one variable, the individual memory locations of which can be referenced and accessed using a numerical index. A single variable of a basic data type or object type can only store and reference one value of that type. So one variable of type "int" called "measurement" can store one int value, like the value "10" this way: int measurement = 10; Now in case we need to store and reference five different measurements, without using arrays we would need to declare five distinct variables of type "int", all named differently: int measurementOne = 10; int measurementTwo = 11; int measurementThree = 12; int measurementFour = 13; int measurementFive = 14; Using arrays, we can declare instead an array variable of type "int" called "measurements" that is of the length 5: int[] measurements = new int[5]; And then we can store our five measurement values into this single int array variable by using the numerical array index in square brackets: measurements[0] = 10; measurements[1] = 11; measurements[2] = 12; measurements[3] = 13; measurements[4] = 14; This way we can use five distinct int storage locations without having to declare and name each one of them separately. Note that the numeric array index references are always zero-based, that is the valid indexes for our array of length 5 were 0 through 4, not 1 through 5.
🌐
TheServerSide
theserverside.com › blog › Coffee-Talk-Java-News-Stories-and-Opinions › Java-array-size-explained-by-example
Java array size, length and loop examples
When you initialize Java arrays with the new keyword, the size argument is of type int. The 32-bit Java int can go to a maximum of 2,147,483,647, so that is the theoretical maximum Java array size.
Published: July 4, 2026
🌐
YouTube
youtube.com › watch
Java Tutorial for Beginners #8 - Arrays
Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.
🌐
freeCodeCamp
freecodecamp.org › news › how-to-create-an-array-in-java
How to Create an Array in Java – Array Declaration Example
March 16, 2023 - The length of an array is fixed when it is created and cannot be changed later. Java arrays can store elements of any data type, including primitive types such as int, double, and boolean, as well as object types such as String and Integer.
🌐
Dev.java
dev.java › learn › creating-arrays-in-your-programs
Creating Arrays in Your Programs
Downloading and setting up the JDK, writing your first Java class, and creating your first Java application.
🌐
Opensource.com
opensource.com › article › 22 › 11 › arrays-java
Use arrays in Java | Opensource.com
In the Java programming language, an array is an ordered collection of data. You can use an array to store information in a structured way. It's useful to know the various ways you can retrieve that data when you need it.
🌐
Igmguru
igmguru.com › home › blog › java › arrays in java
Arrays in Java: Declare, Define, and Access Array
August 11, 2026 - Java Arrays allow you to store multiple values of the same type in a single variable. It is important to understand them for efficient coding whether you are building a simple or complex application.
Top answer
1 of 16
3265

You can either use array declaration or array literal (but only when you declare and affect the variable right away, array literals cannot be used for re-assigning an array).

For primitive types:

int[] myIntArray = new int[3]; // each element of the array is initialised to 0
int[] myIntArray = {1, 2, 3};
int[] myIntArray = new int[]{1, 2, 3};

// Since Java 8. Doc of IntStream: https://docs.oracle.com/javase/8/docs/api/java/util/stream/IntStream.html

int [] myIntArray = IntStream.range(0, 100).toArray(); // From 0 to 99
int [] myIntArray = IntStream.rangeClosed(0, 100).toArray(); // From 0 to 100
int [] myIntArray = IntStream.of(12,25,36,85,28,96,47).toArray(); // The order is preserved.
int [] myIntArray = IntStream.of(12,25,36,85,28,96,47).sorted().toArray(); // Sort 

For classes, for example String, it's the same:

String[] myStringArray = new String[3]; // each element is initialised to null
String[] myStringArray = {"a", "b", "c"};
String[] myStringArray = new String[]{"a", "b", "c"};

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.

String[] myStringArray;
myStringArray = new String[]{"a", "b", "c"};
2 of 16
335

There are two types of array.

One Dimensional Array

Syntax for default values:

int[] num = new int[5];

Or (less preferred)

int num[] = new int[5];

Syntax with values given (variable/field initialization):

int[] num = {1,2,3,4,5};

Or (less preferred)

int num[] = {1, 2, 3, 4, 5};

Note: For convenience int[] num is preferable because it clearly tells that you are talking here about array. Otherwise no difference. Not at all.

Multidimensional array

Declaration

int[][] num = new int[5][2];

Or

int num[][] = new int[5][2];

Or

int[] num[] = new int[5][2];

Initialization

 num[0][0]=1;
 num[0][1]=2;
 num[1][0]=1;
 num[1][1]=2;
 num[2][0]=1;
 num[2][1]=2;
 num[3][0]=1;
 num[3][1]=2;
 num[4][0]=1;
 num[4][1]=2;

Or

 int[][] num={ {1,2}, {1,2}, {1,2}, {1,2}, {1,2} };

Ragged Array (or Non-rectangular Array)

 int[][] num = new int[5][];
 num[0] = new int[1];
 num[1] = new int[5];
 num[2] = new int[2];
 num[3] = new int[3];

So here we are defining columns explicitly.
Another Way:

int[][] num={ {1}, {1,2}, {1,2,3,4,5}, {1,2}, {1,2,3} };

For Accessing:

for (int i=0; i<(num.length); i++ ) {
    for (int j=0;j<num[i].length;j++)
        System.out.println(num[i][j]);
}

Alternatively:

for (int[] a : num) {
  for (int i : a) {
    System.out.println(i);
  }
}

Ragged arrays are multidimensional arrays.
For explanation see multidimensional array detail at the official java tutorials

🌐
Study.com
study.com › business courses › java programming tutorial & training
What is an Array in Java? | Study.com
August 3, 2026 - An array in Java is not an impossibly difficult concept, although many can be confused since it does sound like a very technical term. Rather, an array is simply a sequence of values, where each item is the same data type.
🌐
Baeldung
baeldung.com › home › java › java array › arrays in java: a reference guide
Arrays in Java: A Reference Guide | Baeldung
July 24, 2024 - The length of an array indicates the number of elements in the array and is established when the array is created. After creation, the length is fixed and cannot be changed. Java provides the built-in property length that can be used to determine the length of an array.
🌐
Codecademy
codecademy.com › learn › learn-java › modules › learn-java-arrays-and-arraylists › cheatsheet
Learn Java: Arrays and ArrayLists Cheatsheet | Codecademy
The index of an array starts from 0 and goes up to one less than the total length of the array. ... In Java, an array is used to store a list of elements of the same datatype.