-1

I'm trying to do compare it but I have this query can I compare every condition with one go? Like

if(exp.charAt(i)=='+','-','/','*')

I know I have to do something like this which is correct but i'm trying to find a short way to to this. if(exp.charAt(i)=='+',exp.charAt(i)=='-',exp.charAt(i)=='/',exp.charAt(i)=='*'

  • 1
    Does this answer your question? [How do I determine whether an array contains a particular value in Java?](https://stackoverflow.com/questions/1128723/how-do-i-determine-whether-an-array-contains-a-particular-value-in-java) – Janez Kuhar May 23 '20 at 09:25

1 Answers1

0

You could put the characters into a string, and check if the string contains the specific character in your array:

String matchingCharacters="+-/*";
if (matchingCharacters.contains(exp.charAt(i)))
    ....
CanciuCostin
  • 1,773
  • 1
  • 10
  • 25