diff --git a/AnagramNew.java b/AnagramNew.java new file mode 100644 index 0000000..fb62b57 --- /dev/null +++ b/AnagramNew.java @@ -0,0 +1,19 @@ +import java.util.HashMap; + +public class Anagram { + public static boolean anagram(String oneS, String twoS) { + HashMap oneHM = new HashMap(); + HashMap twoHM = new HashMap(); + for (char c : oneS.toCharArray()) { + oneHM.put(c, true); + } + for (char c : twoS.toCharArray()) { + twoHM.put(c, true); + } + return oneHM.equals(twoHM); + } + + public static void main(String[] args) { + System.out.println(anagram(args[0], args[1])); + } +}