This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes for-loop weird thing. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "for-loop weird thing." Watch "for-loop weird thing." New topic

for-loop weird thing.

Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 798
I found something weird.

Why nothing output ? I think it should display "index=1".

Any help ?

marc weber

Joined: Aug 31, 2004
Posts: 11343

In the for loop, the boolean condition evaluates to false on the first try (when i is zero) because dddd does not contain "0". Therefore, the loop body never executes, and i is never incremented to 1.

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
It is sorta covered in the JavaRanch Style Guide.
subject: for-loop weird thing.
Similar Threads
sorting multidimensional arrays (int)
String tokenizer
Enthuware question: Jsp expression
is it a valid jsp code
Java code review?