String text = "1234"; text.substring(4).startsWith("5"); // is false but works. text.charAt(4) == '5'; // NullPointerExceptionI came across this suttle difference in the String class when chasing a bug in Bodington where we were getting a NullPointerException exception from attempts to split up a URL (don't ask). I'd guess that the charAt is faster (substring creates a new string object) but unless your software is doing 1000s of tests like this it probably doesn't matter.