-3
if (correctAnswer.equals(userChoice.toLowerCase())) {
    System.out.println("Your have provided the correct answer. Well done!");

Where I have .equals above as a String operation, is there a .notequals equivalent for it in Java?

Pshemo
  • 122,468
  • 25
  • 185
  • 269
David N
  • 19
  • 6
  • I removed second question from this post. If you have many questions as them is separate posts. Please see [Can I ask only one question per post?](https://meta.stackexchange.com/q/222735). Here is original version of your post (including removed part) so you could use it in your next question: https://stackoverflow.com/revisions/060615dd-32ba-4e9e-931d-885c22e5efd0/view-source – Pshemo Jan 23 '21 at 15:42

1 Answers1

1

You can use negation operator ! to reverse result of equals method like

if (!correctAnswer.equals(userChoice.toLowerCase()))

Pshemo
  • 122,468
  • 25
  • 185
  • 269
SmilingMouse
  • 132
  • 1
  • 2
  • 15