Hi everybody. First of all happy new year to all. Secondly, I am 3 months into learning Java and GUI and I am having some trouble with comparing strings. I am doing hangman and I have a text field set up for when the player wants to guess the entire word and I can't seem to figure out how to compare when they write a word in with the correct word. For example, if the word is "hello" and they type in "hi", how do I compare them to see if what they typed in is the same as the correct word?
This is what I have tried so far:
String word="relationship";
char array[]=word.toCharArray();
if (guessI.equals("relationship"))
{
System.out.println("Yay it works!!");
}
In what I have tried to write guessI is the text field and relationship is the correct word.
If I am completely mistaken or incorrect in an aspect or completely using the wrong method please explain to me which one would work best.
Thanks a lot.