This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

length of array

 
Aaron Parker
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like this:
for (x = 0; x < fictionTitles.length; ++x) {
Yes, no parantheses - that's a bad design in java.
Tobias
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic