java循环语句问题
- 提问者网友:做自己de王妃
- 2021-04-12 07:02
- 五星知识达人网友:一叶十三刺
- 2021-04-12 07:12
1)
int[] array=new int[1000];
for(int i=0;i<1000;i++){
array[i]=i;
}
2)
while(判断条件){
...
}
3)
do {
...
}while(判断条件);
- 1楼网友:笑迎怀羞
- 2021-04-12 10:46
public class TestForEach { static String[] str = {"数组的第一个元素","数组的第二个元素","数组的第三个元素","数组的第四个元素"};
public static void main(String[] args) { for(String mystr:str) { System.out.println(mystr); } } }
long limit=20; long factoritl =1; for(int i=1; i<=limit; i++){ factoritl = 1; for(int factor=2; factor<=i; factor++){ factoritl *= factor; System.out.println(i+ "i=is" +factoritl); } }
while(true){
System.out.println("s");
}
do{
System.out.println("s");
}while(true)
- 2楼网友:老鼠爱大米
- 2021-04-12 10:08
for循环 . 例如: for(int i = 0; i<10; i++){System.out.println(i);}
while循环 . 例如: while(true){System.out.println("while死循环");}
do-while循环 . 例如: do{System.out.println("while死循环");}while(true);
增强for循环:
例如: String[] a={"a","b","c","d","e"};
for(String i:a){ System.out.println(i);}
- 3楼网友:舍身薄凉客
- 2021-04-12 08:32
for(object o :ob)
{}
while(){}
do{}while()