Make sure you know which methods belong to String, e.g., concat() and which to StringBuffer, e.g., append(). Remember that the substring(int beginIndex, int endIndex) uses a zero-based beginIndex but starts with 1 for the endIndex - (and has en evil lower-case 's' in substring).
But most of all, understand the difference between Strings - immutable objects - and StringBuffers - not-so-immutable objects. i.e.: String s = new String ("Java"); s.concat(" Rules!"); System.out.println(s); StringBuffer sb = new StringBuffer("Java"); s.append(" Rocks!"); System.out.println(sb);
output: Java Java Rocks
why? The line of code s.concat(" Rules!"); created a new String "Java Rules!", but didn't attach a reference to it!