Java - Write code to check if a string contains Only another string array

Requirements

Write code to contains Only

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String stringToMatch = "book2s.com";
        String candidates = "book2s.com";
        System.out.println(containsOnly(stringToMatch, candidates));
    }/*from  ww w . j a  v a  2s  .  co  m*/

    public static boolean containsOnly(String stringToMatch,
            String... candidates) {
        String left = stringToMatch;
        for (final String candidate : candidates) {
            left = left.replace(candidate, "");
        }
        return left.isEmpty();
    }
}