I'm trying to write a recursive program: to compute all strings of length n that can be formed from all the characters given in string, but none of the strings listed in sub are allowed to appear as substrings.
This is the program I have written so far, but it doesn't yet implement the restriction of sub, it only computes the permutations of string.
public static void method(String string)
{
method(string, "");
}
public static void method(String string, String soFar)
{
if (string.isEmpty())
{
System.err.println(soFar + string);
}
else
{
for (int i = 0; i < string.length(); i++)
{
method(string.substring(0, i) + string.substring(i + 1, string.length()), soFar + string.charAt(i));
}
}
}