+ 2
Using Arrays
Please Anyone got how to explain arrays better for learners... Am really getting confused.
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.
+ 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 ;
}
+ 1
Tell us which part didn't you understand well, so we can explain that part specially