| Author |
length() and length.
|
Nabila Mohammad
Ranch Hand
Joined: Nov 05, 2007
Posts: 661
|
|
I understand length() is a method in String class to find the length of the string. But what is length. For eg. Why can't we use length() and where his this length located? [ November 28, 2007: Message edited by: Nabila Mohammad ]
|
The future belongs to those who believe in the beauty of their dreams.Dream BIG!
|
 |
Anil Kumar Saha
Ranch Hand
Joined: Apr 07, 2004
Posts: 111
|
|
Why can't we use length() and where his this length located?
Because, in Java, to get the size of an Array, the language designer prefer to define a field called length, instead of a method length (). The reason is unknown. Since the length is a runtime property, it is not defined anywhere as an API. You can not change the size of an array
|
Regards,
Anil Kumar Saha
SCJP 1.4
http://www.agilej.blogspot.com/
|
 |
Nabila Mohammad
Ranch Hand
Joined: Nov 05, 2007
Posts: 661
|
|
Thanks.. You learn new stuff everyday
|
 |
marc weber
Sheriff
Joined: Aug 31, 2004
Posts: 11343
|
|
|
An array's public final field "length" is described in the Java Language Specification under 10.7 Array Members.
|
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
|
 |
 |
|
|
subject: length() and length.
|
|
|