This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Servlets and the fly likes array length? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "array length?" Watch "array length?" New topic

array length?

darine darine
Ranch Hand

Joined: Mar 08, 2001
Posts: 43
if we an array as: int i[]=new int[10];
the length of it will be : i.length
lenght is looks like a field for the array class.
but when i liiok to that class i can't find a field under that name.please any help.
Chris Stehno
Ranch Hand

Joined: Feb 26, 2001
Posts: 180
Arrays are 'special cases' or 'built in objects or types' of objects ... I'm not sure how to best describe them.
What array class are you looking at the java.lang.reflect.Array class? That class is for use with reflection.
The length of an array is an inherent property of an array.
I belive that it ended up that way as a 'clean up' from C/c++ so that it you can't overrun your arrays and you don't have to count bytes to determine the length.
Hope this helps ....
Chris Stehno (Sun Certified Programmer for the Java 2 Platform)

- Chris Stehno, SCPJ
Tom Barns
Ranch Hand

Joined: Oct 27, 2000
Posts: 138
thanks for the reply,but it is still not clear for me.
any additional help will be appreciated.

Thanks for your help.
I agree. Here's the link:
subject: array length?
It's not a secret anymore!