-3

Currently I'm trying to create a very simple code that can simply just play a strategy game. There is an issue however; I can't seem to get the character comparison to work. Some help please?

 while (nameTwo == "1")

that is my loop checking for if it is the number one in a string, then execute but it is not being read. Any help?

  • 4
    java or javascript? also, give us a little bit more code. The above is either an infinite loop or doesn't loop at all unless you modify nameTwo inside the loop body. – le_m Mar 24 '17 at 01:29
  • 2
    your question is ambiguous. do you want character comparison or string comparison? – Ousmane D. Mar 24 '17 at 01:32
  • duplicate of http://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java – Scary Wombat Mar 24 '17 at 01:38

1 Answers1

0
    I think you're looking for this

     while (nameTwo.equals("1"))
Mr.Aw
  • 216
  • 3
  • 16