Sample sub String code
String text="abc-01-001";
String sub_text=text.substring(7);
System.out.println(sub_text);
This will give "001" as the output.
But in your question two strings are not in same length so the
substring
will not give the correct answer to all strings. So it it better to use
split
method to get correct results. See below code sample,
String []splitArray=text.split("-");
String new_text=splitArray[2];
System.out.println(new_text);
This will also give "001" as the output.