import java.util.*;
import java.lang.*;
import java.io.*;
// The main method must be in a class named "Main".
class Main {
public static void main(String[] args) {
String[] strs = {"eat", "tea", "tan", "ate", "nat", "bat"};
Map<String, List<String>> mapang = new HashMap<>();
for (String s : strs){
char[] ch = s.toCharArray();
Arrays.sort(ch);
String key = String.valueOf(ch);
if(!mapang.containsKey(key)){
mapang.put(key, new ArrayList<>());
}
mapang.get(key).add(s);
}
List<List<String>> anglist = new ArrayList<>();
for(Map.Entry<String, List<String>> entry: mapang.entrySet()){
anglist.add(entry.getValue());
}
System.out.println(anglist);
}
}
To embed this program on your website, copy the following code and paste it into your website's HTML: