【发布时间】:2017-11-29 20:34:29
【问题描述】:
即使输入有下划线,此代码也会返回 false。 输入类似于 1_3/4 + 3 并返回 4_3/4
String[] Separated = fraction.split(" "); //Splits the tokens up
String firstToken = Separated[0]; // I created this to try to troubleshoot
boolean Mixed = true; //This would determine how much I will need to split up
for(int i = 0; i < firstToken.length(); i++) {
if(firstToken.charAt(i) == '_') {
Mixed = true;
}
else {
Mixed = false;
}
}
【问题讨论】:
-
charAt 工作得很好。另一方面,是什么阻止了 Mixed 被设置回 false?
-
哦,对了,我很糟糕,谢谢。
标签: java if-statement charat