r/programming • • Jun 05 '18

Code golfing challenge leads to discovery of string concatenation bug in JDK 9+ compiler

https://stackoverflow.com/questions/50683786/why-does-arrayin-i-give-different-results-in-java-8-and-java-10
2.2k Upvotes

355 comments sorted by

View all comments

Show parent comment

-10

u/ShiitakeTheMushroom Jun 05 '18

Exactly. The code is behaving exactly how we would expect it to. This seems like one of those "gotchas" that you either need to be told about (say, in a post like this), or something you painfully learn after hours of debugging why your application isn't behaving as expected, but it doesn't seem like an error to me.

-1

u/TheDevilsAdvokaat Jun 05 '18

Me either....

That said it pays to be careful when using the increment operator; I've also heard that the pre-increment operator (++n) is slower than the post increment operator (n++)