public class MyClass {
static int start = 0, end = 0;
public static void char_substr(String str, char ch) {
int len = str.length();
for (int i = 0; i < len; i++) {
if (str.charAt(i) == ch) {
start = i;
for (int j = i + 1; j < len; j++) {
if (str.charAt(j) == ch) {
end = j + 1;
break;
}
}
}
if (start != 0)
break;
}
}
public static void main(String args[]) {
String str = "hgdabcvauyec";
char_substr(str, 'a');
System.out.println(str.substring(start, end));
}
}
/*
run:
abcva
*/