File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "for-loop weird thing." Watch "for-loop weird thing." New topic
Author

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 ?

Thanks.
marc weber
Sheriff

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
sscce.org
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: for-loop weird thing.
 
Similar Threads
Enthuware question: Jsp expression
is it a valid jsp code
String tokenizer
sorting multidimensional arrays (int)
Java code review?