Solution in Java

			
public Set<String> getAnagrams(String[] input) {
    Set<String> output = new HashSet<String>();
    outer: for (int i = 0; i <= input.length - 1; i++) {
        for (int j = i + 1; j <= input.length - 1; j++) {

            if (input[i].length() == 0)	continue outer;
            if (input[j].length() == 0)	continue;
            if (input[i].equals(input[j])) {
                output = addAnagram(output, input[i]);
                continue outer;
            }
            String sortedI = sortString(input[i]);
            String sortedJ = sortString(input[j]);
            if (sortedI.equals(sortedJ)) {
                output = addAnagram(output, input[i]);
                continue outer;
            }
        }
    }
    return output;
}
	
private Set<String> addAnagram(Set<String> output, String str) {
    for (String out : output) {
        if (sortString(out).equals(sortString(str)) return output;
    }
    output.add(str);
    return output;
}