My input: "professions/medical/doctor/"
My desired output: "doctor"
I have the following solution but it is not a one-liner:
String v = "professions/medical/doctor/";
String v1 = v.substring(0, v.length() - 1);
String v2 = v1.substring(v1.lastIndexOf("/")+1, v1.length());
System.out.println(v2);
How can I achieve the same in a one-liner?