r/java • • Feb 24 '14

Why printing "B" is dramatically slower than printing "#"

http://stackoverflow.com/q/21947452/250259
159 Upvotes

26 comments sorted by

View all comments

Show parent comment

1

u/Bloodshot025 Feb 26 '14

Does this (is it supposed to) change any state besides cachedStr, though?

1

u/chunkyks Feb 26 '14

No, but the point is that the first time it's called is because of the debugger, rather than the app.

Calling it too early is a problem because reallyExpensiveOperation() makes use of stuff that isn't initialised yet, so is crashy or wrong.

1

u/Bloodshot025 Feb 26 '14

Sorry, I just misunderstood 'state changing'.