输入迭代通过字符串
preBody = The AThe CThe IThe O{
我试图让输出作为
The A
The C
The I
The O
和忽略的值小于5(bodyCnt)[{]
到目前为止我是的。
int bodyCnt = 5
int cnt = 0;
String eachBody;
int extra = 0;
int limit = preBody.length();
while(limit >= bodyCnt){
eachBody = preBody.substring((cnt+extra), (bodyCnt+cnt));
cnt = eachBody.length();
extra = 1;
limit = limit - eachBody.length();
System.out.println("eachBody : -----"+eachBody);
}
输出
eachBody :----- The A
eachBody :----- The C
eachBody :----- The C
eachBody :----- The C
后第2次循环中的数据相同。
我做错了什么。
或者我们可以用更好的方法来解决吗?
向下选民请评论 –