Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keyword length returning a value in java for an array

I see that length of an array is a keyword in java and that String has a method length().

How can a keyword return a numeric value, when it is not explicitly declared to do so?

like image 980
Koushik Balaji Venkatesan Avatar asked Aug 12 '26 06:08

Koushik Balaji Venkatesan


1 Answers

array has a public final int field length for array class

from jls-10.3

The public final field length, which contains the number of components of the array (length may be positive or zero).

like image 118
jmj Avatar answered Aug 13 '26 21:08

jmj