3 ms·
That style of code is pretty unusual in Java. Most of the time you would just use a for loop.
by blaisio 8y ago
That style of code is pretty unusual in Java. Most of the time you would just use a for loop.
- bradleyjg 8y agoOr given that it's java 9 something with streams.
- kllrnohj 8y agoThere's a lot of cases where you can't "just use a for loop" such as if you're looping over something else, or if you're looping over 2 things. For example replace it with something like: data[i++] += other[j++] Yeah you could do this other ways, but it's not actually uncommon. You'll see this sort of thing in collection implementations regularly, for example, or things doing parsing. Not necessarily with the append operator as well, but certainly indexing into an array with a ++ variable.