java--for循環,一個分號的區別


public class Test {
 public static void main(String[] args) {
  int x=1;
  int y=1;
  for(System.out.println("a");x<3;System.out.println("b"),x++);{
   System.out.println("c");
  }
  System.out.println("*******************************");
  for(System.out.println("a");y<3;System.out.println("b"),y++){
   System.out.println("c");
  }
 }
}
輸出結果如下:
a
b
b
c
*******************************
a
c
b
c
b

在第一個for循環後面加一個分號,輸出結果完全不一樣。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章