Java inherited an awkward for-loop statement from the C Programming Language. When Java was developed, most programmers were coding in C or C++. The authors of Java felt that they would get the greatest acceptance in the programmer community if the syntax of Java resembled that of C/C++, but without the disadvantages that we have with that low-level language. Quite a few of the idiosyncrasies of C have thus leaked through into Java.
In this section we look at how the for-loop works and how it could have been written with a while-loop instead. Both are used, but the for-loop is more common.
We hope you enjoyed this tutorial. If you did, you will also enjoy our courses. We suggest you start with Extreme Java - Advanced Java, followed by Extreme Java - Concurrency Performance for Java 8.
We deliver relevant courses, by top Java developers to produce more resourceful and efficient programmers within their organisations.
We can help make your Java application run faster and trouble-shoot concurrency and performance bugs...