为什么这段代码行为正确?我被告知多行循环体应该总是有花括号
public class Sample {
public static void main(String[] args)
{
int[] nums = {1,2,3,4,5,6,7,8,9,10};
// print out whether each number is
// odd or even
for (int num = 0; num < 10; num++)
if (num % 2 == 0)
System.out.println(num + " is even");
else
System.out.println(num + " is odd");
}
}