【发布时间】:2023-03-06 22:58:01
【问题描述】:
这是我的代码:
for (Article a : articles) {
boxNumber = magazine.getFfd().searchArticleInBox(a);
if (boxNumber >= 3) {
text = text + "Place box " + boxNumber + "\n";
}
}
textArea.append(text);
它确实有效:
Place box 3
Place box 3
Place box 3
Place box 3
Place box 4
Place box 4
这不是我想要的。我希望有人能告诉我当数字改变时我是如何得到它的,所以我得到:
Place box 3
Place box 4
【问题讨论】:
-
存储最后一个数字并测试
doosnummer是否相同,如果不一样打印出来并更新最后一个数字的值 -
你能在你的代码中使用英文单词吗?它使我们更容易理解代码。
-
@ThomasBöhm 对于这个琐碎的代码应该无关紧要
-
有没有可能在3、4之后又来3?