I'm reading C++ 101 Rules Guidelines and Best Practices, and at item 28, they state that post increment operator should be avoided if we don't need the old value of the variable, as this operator creates a copy of it, hence a tiny performance loss.
I was wondering if Java did this operation the same way, in which case prefix operator should also be prefered for for-loop statements (the ones that might not be suited to a for-each or a lambda forEach() statement)
Java specs tell (§15.14.2):
The value of the postfix increment expression is the value of the variable before the new value is stored
So, is there some new object created at any time during the operation ? As we're returning something different than the variable that's been incremented.