Ask a Teacher



What do you mean by arrays? Why is it important in java?

An array in java is a collection of items stored into a single unit. The array has some number of slots(elements), each slot in the array can hold an object or a primitive value. Arrays in java are objects that
an be treated just like other objects in the language

Arrays can contain any type of element value , but we can't store different types in a single array. Wecan have an array of integers or an array of strings or an array of arrays.

To create an array in java ,use three steps

1. Declare a variable to hold the array

2. Create a new array object and assign it to the array variable

3. Store things in that array




comments powered by Disqus