if(input.charAt(i) == '0' || input.charAt(i) == '1' || input.charAt(i) == '2') {
}
有没有办法压缩这个 if 条件,或者没有?
最佳答案
您可以检查该字符是否与公共(public)String
中的任何索引匹配。就像,
if ("012".indexOf(input.charAt(i)) > -1) {
}
关于java - 有没有更干净的方法来执行此 if 语句?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60406373/