Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
次のようなif条件を作りたい:
if(token[0].equals(("MOVE")|("NOT")|("AND")) { }
Orelse これを行う他の方法はありますか?
もちろん、以前の答えは正しいですが、別の選択肢をもう1つ提案します。
if (token[0].matches("MOVE|NOT|AND")) { ... }
これは少し非効率的で、古典的な正規表現の乱用ですが、簡潔で、あなたが書いていたものに精神的に近いものです。