File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes length of array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "length of array" Watch "length of array" New topic

length of array

Aaron Parker

Joined: Jan 31, 2004
Posts: 27
How do I find out how long an array is (number of elements). How do I do that in Java?
My first incorrect guess was (as a oondition in my for loop):
for (x = 0; x < length(fictionTitles[]); ++x) {
Tobias Hess
Ranch Hand

Joined: Apr 06, 2004
Posts: 55
Like this:
for (x = 0; x < fictionTitles.length; ++x) {
Yes, no parantheses - that's a bad design in java.
I agree. Here's the link:
subject: length of array
It's not a secret anymore!