+ 1

How arrays can be useful and where it is used ?

9th Jul 2016, 9:22 AM
Vinod Luhar
6 Answers
+ 2
arrays can be used to store a number of values of same type in a single name
9th Jul 2016, 9:50 AM
sreeraj g
sreeraj g - avatar
+ 2
An array is a way of placing values into an indexed list. Let's say you have a bunch of names you need to store in your program. You can create a variable for each name(name1 = "Bob", name2 ="Rick" etc.. which is a lot of variables to deal with or you can simplify it by putting them in an array. String[] names = new String[number of names]; Each name you add will index starting at 0 all the way to the max number you set. Can easily cycle through them all with a for loop for easy printing or just make changes without accessing a different variable each time
9th Jul 2016, 10:22 AM
James - avatar
+ 2
lets say you wanted to calculate the average score for a test. Instead of making a variable for each student, you could make an array with one variable to hold all the test scores. you can then loop through the array adding all the values. divide by the length of the array. bam average score on test.
9th Jul 2016, 10:23 AM
seraphimx - avatar
not proper answer
9th Jul 2016, 10:06 AM
Vinod Luhar
Thanks guys . Like my question plZ
9th Jul 2016, 10:40 AM
Vinod Luhar
Imagine a librarry containing books of different genres. then it there will be different cupboard for different genres. like novel in one, biographies in second.... if tge lybrary has got a new novel it will store it in first cupboard... in array...data type is that genre...and related syntex is cupboard.... hope it will help you....
21st Jul 2016, 2:07 PM
Harshil Soni
Harshil Soni - avatar