+ 2

Using Arrays

Please Anyone got how to explain arrays better for learners... Am really getting confused.

19th Feb 2018, 4:42 PM
Samuel Obadina
Samuel Obadina - avatar
3 Réponses
+ 3
Array is way that allows us to store multiple variables of same data type. For example: String[] colors = {"Red", "Green", "Blue", "Yellow", "black"}; I do not need to create new variables for each color.
19th Feb 2018, 2:59 PM
Sad
Sad - avatar
+ 3
Other example, if you need to store 1024 names, instead of declarate 1024 variables you can declare one array of names and access them by the index: string name1 = "name1"; string name2 = "name2"; string name3 = "name3"; .... string name1024 = "name1024"; / ***** using array ******/ String[ ] names = new String[1024]; for(int i = 1; i <= names.length; i++){ names[i] = "name" + i ; }
19th Feb 2018, 3:14 PM
J Domingo Jiménez J
J Domingo Jiménez J - avatar
+ 1
Tell us which part didn't you understand well, so we can explain that part specially
19th Feb 2018, 3:04 PM
Sad
Sad - avatar