Array initialization in Java is the process of creating an array and assigning values to it. Java provides multiple ways to initialize arrays depending on when and how the values are known.
// Array declaration with size and default initialization
int[] numbers = new int[5];
System.out.println(numbers[0]);
// Array initialization using literal values
int[] marks = {90, 85, 78, 92};
System.out.println(marks[2]);
// Initializing array using new keyword with values
String[] names = new String[]{"Java", "Python", "C++"};
System.out.println(names[1]);
Enter values separated by commas to see how Java stores them in memory with 0-based indexing.
When an array is created with a fixed size, Java assigns default values (0 for integers, null for objects). Using array literals allows direct assignment of values and automatic size calculation.