+ 1
Can anyone show an example what this means
//An array is a collection of variables of the same type that are referenced by a common name.?//
3 Respuestas
+ 11
// When you need to store a list of values, such as numbers, you can store them in an array, instead of declaring separate variables for each number.
int[] arr = {12, 11, 10, 44, 37};
/*
We just have one name for 5 different elements (i.e., arr), if we didn't use arrays here, then we have to declare 5 different variables (like x = 12, y = 11,...) and that results in performance degradation. We can now print any element from our array arr...*/
System.out.print(arr[2]);
+ 11
@David Your question is already answered in your previous post, have a look at it ^^
+ 1
thanks dayve, i felt like it was saying that the collection of elements were called a collection of variables when inside an array which i think is a poor way to word it
maby its right in a way for example
array[0] = 12
array[1] = 11
array[2] = 10 ect...
but really its 5 elements in an array that share 1 variable which is distinguished from one another using []