0

When I run this code it returns 3 (as I expected) however j prints 0. Could someone explain why this happens.

 int i, j;
 i = 3;
 j = i;
 j = j/9*6;
 System.out.println(i);
 System.out.println(j);
Peter
  • 39
  • 6

1 Answers1

0

You are performing integer division, so j/9 will evaluate to 0, then 0*6 == 0.

th13
  • 41
  • 5