if (x = y != z)
tests if x is equal to y OR z.
How do I do this for .equals?
like:
if (x.equals("Hello" or "World")
Printable View
if (x = y != z)
tests if x is equal to y OR z.
How do I do this for .equals?
like:
if (x.equals("Hello" or "World")
That is not how to compare multiple values in Java. What that code does is assign x the value of y, then checks to make sure that x is not equal to z.
You need to use the logical or operator || to chain together multiple conditions using logical or.
Code java:
if(x == y || x == z)
The same logical code statement applies to .equals:
Code java:
if(x.equals(y) || x.equals(z))
Thanks :)
Helped me!