Comparing Each Character in Java String
- by user2760357
I am a beginner at java, and I am trying to create two strings and compare each character.
If there is a matching character or characters, the code has to print out the length of each string, without the matching characters.
For example, if one string is "super," and the other is "perfect," the program should interpret the strings as superfect, and print out 9
However, if there is no matching part, like pencil and eraser, the code should printout 12, which is the length of two strings combined.
Right now, I am having a problem with comparing each character, since I tried to use
if(input_word.compareToIgnoreCase(input_word2) != 0)
but it only compared the string as a whole..
any suggestion?
Thank you for your efforts