Situation:
I have been downloading a .java-file from the internet.
It's pretty messy, and I have cleaned a lot of the code with Java Docs in mind.
However:
The author of the code seems to practice three to four different ways of writing the for-loop, making it super-hard for me to debug.
Example 1 (This is the form I like):
for (int i = 0; i < x; i++) {
. . //Action inside the for-loop.
}
Example 2 (I can understand this one):
for (int i = 0; i < x; i++) //Action inside the for-loop.
Example 3 (It becomes harder...):
for (int i = 0; i < x; i++)
. . //Line 1
//Line 2
//Line 3
Example 4 (I'm totally lost):
for (int i = 0; i < x; i++)
. . //Line 1
//Line 2
for (int i = 0; i < x; i++) //Line 3
for (int i = 0; i < x; i++)
. . //Line 4
//Line 5
//Line 6
//Line 7
Question
The for-loop format i name "Example 1" is so clean; it got brackets and is tabbed.
Why are they using the other formats? Are they cooler than the first example?
How are the for-loops in example 4 working? Are they inside each other?
Thanks for your time and answers.