java如何让数组里的字符串循环输出

package Itniwo;

public class fors {
public static void main(String[] args) {
String[] strings = {"你好", "哈哈", "江山", "美人"};

}
}
每输出一个中间阁5秒的时间

通过for循环后把数组中的字符串输出

1、定义字符串数组

String arr[] = new String[]{"a","b","c"};//定义一个字符串数组arr

2、循环数组

for(int i=0;i<arr.length;i++){//通过arr.length获取字符串数组长度
   System.out.println(arr[i]);//循环输出字符串数组元素
}

温馨提示:答案为网友推荐,仅供参考
第1个回答  推荐于2017-09-11
String[] strings = {"你好", "哈哈", "江山", "美人"};
for(String str:strings){
System.out.println(str);
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}本回答被提问者采纳
第2个回答  2012-03-15
public class fors {
public static void main(String[] args) {
String[] strings = {"你好", "哈哈", "江山", "美人"};
for(String string : strings){
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.print(string);
}
}
}
第3个回答  2012-03-15
public class TestCirculation {
public static void main(String[] args) {
String[] string = { "你好", "哈哈", "江山", "美人" };
for (int i = 0; i < string.length; i++) {
System.out.println(string[i]);
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

}

}
第4个回答  2015-09-28
int[] i = 自己定义的数组;
for(int i=0;true;i++){
System.out.println(i[i%i.length]);
}
相似回答