2
我不知道如何編寫「下一個源字符」代碼來查找字符串的下一個字符。如何在Java語法分析器的掃描器中取下一個字符
public class scanner {
protected char currentChar;
protected StringBuffer currentSpelling;
protected byte currentKind;
private void take (char expectedChar){
if (currentChar == expectedChar){
currentSpelling.append(currentChar);
currentChar = next source character;
}
}
private void takeIt(){
currentSpelling.append(currentChar);
currentChar = next source character;
}
}
使用for循環。使用索引* String * .charAt() - 方法&你去。 – Seth