Does anyone know how to write an anagram checker code in Java | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Does anyone know how to write an anagram checker code in Java

I am doing (string fundatmentals) homework and an optional bonus question asks us to write a basic java code that can check if two strings are anagrams of one another. So far, I understand that they have to be the same length and same number of letters, but i just can't figure out how to build that. I have an if statement that checks the length of both strings but after that I'm lost. Please help and thank you for your time!

11th Jan 2020, 3:09 PM
Christian Falzone
Christian Falzone - avatar
2 Answers
0
Ok I saw, on a google search, references to first use .toCharArray() and then Array.sort().. this looks like it will work. I guess I was looking for a simple string method to solve it since we haven't learned about importing classes yet. But thank you!
11th Jan 2020, 3:44 PM
Christian Falzone
Christian Falzone - avatar
0
Oh that's probably what they wanted. Wow no wonder it was optional. Haha thanks again!
11th Jan 2020, 4:43 PM
Christian Falzone
Christian Falzone - avatar