answersLogoWhite

0

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 can 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. We can 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

User Avatar

Wiki User

15y ago

Still curious? Ask our experts.

Chat with our AI personalities

JudyJudy
Simplicity is my specialty.
Chat with Judy
SteveSteve
Knowledge is a journey, you know? We'll get there.
Chat with Steve
RossRoss
Every question is just a happy little opportunity.
Chat with Ross
More answers

int size=10;

int a[]=new Int[size];

this is static initialization;

int aa[]=null;

int size;

size you can take from your applicatin

aa[]=new int[size];

this is what dynamic initialization

User Avatar

Wiki User

14y ago
User Avatar

Add your answer:

Earn +20 pts
Q: How do you initialize an array variable in java program?
Write your answer...
Submit
Still have questions?
magnify glass
imp