Java program to check if a supplied list of words are anagrams to each other.