while循環
while( 布爾表達式 ) {
//循環內容
}
do...while循環
do {
//代碼語句
}while(布爾表達式);
//相對於while循環他會至少執行一次do裏面的代碼
for循環
方式一
for(初始化; 布爾表達式; 更新) {
//代碼語句
}
方式二
for(聲明語句 : 表達式)
{
//代碼句子
}
例如
int [] numbers = {10, 20, 30, 40, 50};
for (int x : numbers){
System.out.println(x);
}
//類似python中的 for a in {10, 20, 30, 40, 50}