Java - Write code to get After Separator Or All

Requirements

Write code to get After Separator Or All

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String name = "book2s.com";
        System.out.println(getAfterSeparatorOrAll(name));
    }/* w w w.  jav  a2 s .  co  m*/

    private static final String SEPARATOR = ":";

    public static String getAfterSeparatorOrAll(String name) {
        int index = name.indexOf(SEPARATOR);
        if (index == -1)
            return name;
        else
            return name.substring(index + 1);
    }
}

Related Exercise