0
How works array length? Pls help
int[ ] intArr = new int[5]; System.out.println(intArr.length); //Outputs 5 PLS EXPLAIN THIS
4 Respostas
+ 12
In the first line you define an array with 5 elements. So the array has the length 5.
This is what is pronted in the 2nd line (=output).
Btw, how did you manage to go through one third of the Java course and only gaining 7 xp?
+ 2
Arrays are static memory allocation, so if you initialize an array with 10 elements, The length property will return the allocated size of the array.
How the array length works exactly I don't know, because the implementation of the length property is no where. It is the part of the core.
+ 1
i dont know :p
+ 1
thanks