Java Substring Length: How to Get It Right & Avoid Common Bugs