它必须输出像这样的01234
for(int i = 0;i < 5; i++, System.out.print(i));或
for(int i = 0;i < 5; System.out.print(i))
    i++;产出: 12345
发布于 2022-10-24 17:48:43
for(int i = 0;i < 5; System.out.print(i))
    i++;等效于以下while循环:
{
  int i = 0;
  while (i < 5) {
    i += 1;
    System.out.print(i);
  }
}i在打印之前总是递增。i++, System.out.print(i)也是如此:在打印i之前,它已经增加了。我不需要提到0+ 1 =1。
发布于 2022-10-24 18:59:40
这很容易,你只需要明白你在写什么。应该是这样:
for(int i=0;i<5;i++){ //"i" is increased at the end of the loop
    System.out.print(i) //prints "i", which is zero and will increase up to 4
}就这样
https://stackoverflow.com/questions/74184933
复制相似问题