0

I have this code:

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

The output in LogCat is correct:

0
1
2
3
6

But when I change System.out.println(i); for System.out.println("hi"); or any other object or number the output in LogCat is:

hi
hi

It should be a 5 xhi list. Is this a bug in Android or is it my system? Thanks in advance.

Ricardo
  • 1,018
  • 2
  • 9
  • 13

1 Answers1

1

System.out.println() is compatible with Android. Im not sure what you are doing, but when I run the code you gave I get the following outputs:

(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

I believe its a bug in either your system or the version of Android you are running. I can tell you the output above was running on API 15.

appman0724
  • 11
  • 2
  • I'm using API 17, also de Log.i() method fails, I'll dig in and see what I can do. Thank you very much. – Ricardo Jun 30 '13 at 00:49