【发布时间】:2018-11-17 22:50:05
【问题描述】:
在将输入设置为在 while 循环中输入后,如何重置 char 文本中的输入。经过while循环后,它应该从头开始。 例如
char text = In.read();
假设我输入了asdf
while(text != '\n' ) {
text = In.read();
}
//here is text = enter
但我希望它再次来自 asdf 的“a”。
这是我目前得到的结果
System.out.print("Please enter your text ");
char text = In.read();
// some other code here
//...
for (int i = 0; i < textcount.length ; i++)
{
j = 0;
while(text != '\n' )
{
int a = Character.getNumericValue(textcount[i]);
int b = Character.getNumericValue(text);
if(a == b)
{
j++;
charCounts[i] = j;
}
text = In.read();
}
}
【问题讨论】: