1

i'm taking user input from

String riddle=b.readLine();
riddle1=Integer.parseInt(riddle);

and obviously, i'm trying to get the user to answer a riddle. I tried using the following

if(riddle1=="answer")

but that doesn't work

Nayantara Jeyaraj
  • 2,624
  • 7
  • 34
  • 63
dofoolee
  • 11
  • 2

1 Answers1

1

Try this

riddle.equals("answer");

As == doesn't checks whether both strings are equal or not, it compares string's location.

You can click here for more information about it.

Shunan
  • 3,165
  • 6
  • 28
  • 48