Here you go:
subtring method:
int start = 1;index method:
int end = 4;
String substr = "aString".substring(start, end); // Str
String string = "madam, i am Adam";Here is a live example I am working with where I need to parse the String into two variables as my webpage is passing me a parameter that is pipe-delimited:
// First occurrence of a c
int index = string.indexOf('a'); // 1
String str = "YES|12345";
int pipe = str.indexOf('|'); //4
String firstPart = str.substring(1,pipe-1);
String lastPart = str.substring(pipe+1);