Filter by Tags

How do I declare and initialize an array in Java ?



0 0

Using Java, how can I declare and initialize an array.

Open E-School
Posted on : Thu, Jan 18, 2018
Views : 75

Ask Question

If you want to ask question you must LogIn or SignUp
Login SignUp

Answers (1)


In Java we can declare and initialize arrays in the following manner

int[] array = new int[10];
int[] array = {1,2,3,4,5};
int[] array1 = new int[]{1,2,3};

Also, we can initialize the array values by using a for loop

int[] array = new int[5];
int count = 0;
for(count = 0 ; count < 5 ; count++)
    array[count] = count;
for(count = 0 ; count < 5 ; count++)

Ravinder Singh
Thu, Jan 18, 2018

Edit Answer

This answer will permanently deleted. Do you really want to delete this Answer ?
To Add your Answer Please
LogIn | SignUp

Quick Links



Total Followers
Study Group Created
Study Group Joined
Following Teacher
Following Organization
Blog Articles Added
Questions Asked
Questions Answered
Jobs Posted
Total Members in Group
Questions asked by members
Tasks added in this Group

Please wait..


Login to Open ESchool OR Create your account    Login   SignUp