Java - Write code to remove Prefix


Write code to remove Prefix


//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String str = "";
        String prefix = "b";
        System.out.println(removePrefix(str, prefix));
    }/*from   ww w.  j  av a 2  s.  co m*/

    public static String removePrefix(String str, String prefix) {
        if (str.startsWith(prefix)) {
            return str.substring(prefix.length());
        return str;

Related Exercise