Home / Questions / What is an array? Write a statement to declare an integer array of 10 elements.
Explanatory Question

What is an array? Write a statement to declare an integer array of 10 elements.

👁 125 Views
📘 Detailed Answer
🕒 Easy to Read
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.

Answer with Explanation

An array is a data structure that stores a fixed-size sequence of elements of the same type. It allows you to store multiple values in a single variable, with each value being accessed by its index or position in the array.

Here's a statement to declare an integer array of 10 elements in Java:


int[] array = new int[10];

In this statement:

  • int[] specifies that array will be an array of integers.
  • new int[10] creates a new array that can hold 10 integer values, with all elements initialized to 0 by default.