0

Im novice in java coding. Could someone tell how to make this code work. I'm trying to a simple guessing game for string variable (as an exercise). I know how to do it with numbers but with words it seems to go differently. I'm trying to make the program ask word until it's correct (java).

public class DoWhile2 {
    public static void main(String[] args) {

    String word;

    do {
        System.out.println("Guess the right word.");
        word = In.readString();

        if (word != "java")
             System.out.println("Try again.");

        else
             System.out.println("Good.");

    }while (word != "java");

}}
Deloss
  • 1

0 Answers0