File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes length() and length. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "length() and length." Watch "length() and length." New topic
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: length() and length.
 
Similar Threads
Adding strings together
array
Sort an array alphabetically and by length
Local variable
Salutations. =]