• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Tim Cooke
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
Saloon Keepers:
  • Piet Souris
Bartenders:

About array in Java

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why we use length() to calculate the length of a string,
but "length" to compute the length of an array?

Is the "length" attribute in an array a public instance
variable?

Thanks!
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by C Law:
...Is the "length" attribute in an array a public instance variable?


Yes. "The array's length is available as a final instance variable length." (Ref: JLS - Section 10.3.)
[ March 21, 2006: Message edited by: marc weber ]
 
author
Posts: 4356
45
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by C Law:
Why we use length() to calculate the length of a string,
but "length" to compute the length of an array?



Old naming conventions. We also use size() on java collections including arraylists so don't think the confusion stops at strings and typed arrays.
[ March 21, 2006: Message edited by: Scott Selikoff ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic