This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Is it quicker? Is it more elegant? Is it more maintainable!?! (Look at that 3 questions from one pointless statement! *is proud*)
Surely it's going to be compiled into pretty much the same thing, it's doing the same number of operations, after all, so surely it won't be any quicker? (I should mention that I have next-to-no understanding of the lower-level Java stuff, so I'm probably completely wrong here...)
More elegant? I guess if by 'elegant' you mean, 'harder to understand, easier to introduce bugs, but 1 character shorter', then yes, it's more elegant, but really?
Ummmm... yes it is correct. Or rather, it would be correct if we replace 'l' with 'i'. Note that --i >= 0 is evaluated at the beginning of the first iteration, so the first value that appears within the loop is arr.length - 1, which is fine. Apparently it's not considered very readable to most people.
[victor]: ( and more elegant )
You may have a hard time finding people who agree with you there.
[David]: so surely it won't be any quicker?
Don't be too sure. It may indeed be slightly quicker on some platforms. May also be slightly slower. Performance differences can be hard to predict, and can vary from platform to platform. What I will agree with is that performance differences in this code will usually be trivial compared to readability differences.
Anyway, as EFH said, more discussion is available here.
"I'm not back." - Bill Harding, Twister
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com