public class Anagram
extends java.lang.Object
The provided code is incomplete. Modify it so that it works properly and passes the tests in
AnagramTest.java
.
Constructor | Description |
---|---|
Anagram() |
Modifier and Type | Method | Description |
---|---|---|
static boolean |
areAnagrams(java.lang.String first,
java.lang.String second) |
Given two strings return true if they are anagrams of each other.
|
static void |
main(java.lang.String[] unused) |
Solicits two strings from the user and print if they are anagrams.
|
public static boolean areAnagrams(java.lang.String first, java.lang.String second)
Two strings are anagrams if they contain the same letters but in a different order. You should ignore case, punctuation, and whitespace. So only consider the letters A-Z, a-z, and the numbers 0-9. And you should also require that the anagram use the same letters the same number of times. (Some anagram definitions are more flexible.)
Either the first or second string may be null, in which case you should return false. Empty strings require no special treatment.
first
- the first string to use for the anagram comparisonsecond
- the second string to use for the anagram comparisonpublic static void main(java.lang.String[] unused)
You are free to review this function, but should not modify it. Note that this function is not tested by the test suite, as it is purely to aid your own interactive testing.
unused
- unused input arguments