Substring is one of the most useful method from Java.lang.String but incorrect use of it can cause memory leak in Java. There are two overloaded version of substring method, one, which takes start index, and other with takes both start and end index.