0

我有这个代码:

for (int i = 0; i < 9; i++) {
    if (i <= 3 || i% 3 == 0) {
        System.out.println(i);
    }
}

LogCat 中的输出是正确的:

0
1
2
3
6

但是,当我更改System.out.println(i);任何System.out.println("hi");其他对象或编号时,LogCat 中的输出是:

hi
hi

它应该是一个 5 xhi列表。这是Android中的错误还是我的系统?提前致谢。

4

1 回答 1

1

System.out.println() 与 Android 兼容。我不确定您在做什么,但是当我运行您提供的代码时,我得到以下输出:

(System.out.println("hi");)
06-29 20:42:43.645: hi
06-29 20:42:43.645: hi
06-29 20:42:43.645: hi
06-29 20:42:43.645: hi
06-29 20:42:43.645: hi

(System.out.println(i);)

06-29 20:44:00.380: 0
06-29 20:44:00.380: 1
06-29 20:44:00.380: 2
06-29 20:44:00.380: 3
06-29 20:44:00.380: 6

我相信这是您的系统或您正在运行的 Android 版本中的错误。我可以告诉你上面的输出是在 API 15 上运行的。

于 2013-06-30T00:45:32.873 回答