Where does the Array use in java | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 13

Where does the Array use in java

Usage of java

28th Mar 2019, 8:19 PM
Amir Afsari
Amir Afsari - avatar
10 Answers
+ 32
Arrays are used for storing and manipulating variables of the same type. If you mean the Arrays class it has some very useful methods, such as sorting - sort(), comparing the values - equals(), turning an array to a string - toString() and I'm sure a lot more that I don't know of yet :))
28th Mar 2019, 9:35 PM
1Lory☕
1Lory☕ - avatar
+ 13
When you need to use lot of data,same data type & update, delete & modify that time you use Array or array list.You must be import array or arraylist.Array class have an lot of method , you call this method for data upadate or modify,delete.You just practice it, then you will realise.
30th Mar 2019, 3:47 AM
Nasir❤
Nasir❤ - avatar
+ 7
Extra information: - you can store multiple variables of the same type - different types is not allowed - length of an array is immutable
30th Mar 2019, 10:31 AM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar
+ 7
Basically, you are asking for the "situation", where you should use arrays. So, the answer is quite simple. The answer is: - 1.when you have to store multiple values without using multiple variables. 2.when you have to manipulate some kind of data which has a same data type. 3.Also, for other reasons, can be used to analyze data. Basically, you use it to store a 'set' of data which have the same data type.
30th Mar 2019, 12:56 PM
Ayush Sinha
Ayush Sinha - avatar
+ 6
For example, in each frame of a platform game, when you are performing collision test on player and each of the enemies, you will use loop running on an array of enemy objects.
29th Mar 2019, 5:59 AM
Gordon
Gordon - avatar
+ 5
Note that elements in the array are identified with zero-based index numbers, meaning that the first element's index is 0 rather than one. So, the maximum index of the array int[5] is 4.
29th Mar 2019, 5:07 PM
Luka
+ 3
When you have to deal with lots of same data type, you will really need it! Like you want to create and store some numbers like factorials or Fibonacci series.
29th Mar 2019, 10:13 PM
Aaron Yang
Aaron Yang - avatar
+ 2
When your program needs to store much more data that has same data type which is necessary to modify.
30th Mar 2019, 3:54 AM
Mesut Awahab
Mesut Awahab - avatar
+ 2
So that you don't need to declare multiple variables what will you do if you want to take 100 inputs and find there average
31st Mar 2019, 4:29 PM
Rajb957
Rajb957 - avatar
+ 2
....
1st Apr 2019, 7:22 AM
Manjit Kumar Pradhan
Manjit Kumar Pradhan - avatar