• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

length() and length.

 
Nabila Mohammad
Ranch Hand
Posts: 664
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Anil Kumar Saha
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Nabila Mohammad
Ranch Hand
Posts: 664
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks..
You learn new stuff everyday
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An array's public final field "length" is described in the Java Language Specification under 10.7 Array Members.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic