I am trying to find anagrams of subsets of letters in a word; for example, if the word is "hello", the program will check the whole word, then the word with 1 letter missing and so on.
Here is my code, I'm not sure where I am doing wrong:
import java.util.*;
import java.io.*;
class Perm {
public static void main(String[] args) {
System.out.println(permutations("hello"));
}
public static String permutations(String word) {
String s = "";
for(int i=0; i<word.length(); i++) {
char ithChar = word.charAt(i);
String newWord = word.substring(0,i) + word.substring(i+1);
s = permutations(newWord);
}
return s;
}
}