Java - Write code to get substring After First delimiter

Requirements

Write code to get substring After First delimiter

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String string = "book2s.com";
        String delimiter = "book";
        System.out.println(substringAfterFirst(string, delimiter));
    }/*w  ww.  ja v a 2  s. co  m*/

    public static String substringAfterFirst(String string, String delimiter) {
        final int index = string.indexOf(delimiter);
        if (index == -1) {
            return "";
        }
        return string.substring(index + delimiter.length());
    }
}

Related Exercise