Write code to remove Start the start of a string
abc becomes bc
Use String.startsWith() method to check if the string is starting with another string.
public class Main { public static void main(String[] argv) { String str = "book2s.com"; String started = "book"; System.out.println(removeStart(str, started)); }//from ww w.j a v a 2 s . c om public static String removeStart(String str, String started) { if (isEmpty(str) || isEmpty(started)) return str; return str.startsWith(started) ? str.substring(started.length()) : str; } public static boolean isEmpty(String str) { return str == null || str.length() == 0; } }