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 w ww  .j  a v  a  2  s.c  o m*/

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