温馨提示×

java字符串数组如何输出

小亿
100
2023-11-30 15:49:25
栏目: 编程语言

使用for循环遍历字符串数组,然后将每个字符串都输出出来。代码如下所示:

public class Main {
    public static void main(String[] args) {
        String[] strArray = {"Hello", "World", "Java"};
        
        for (String str : strArray) {
            System.out.println(str);
        }
    }
}

输出结果为:

Hello
World
Java

这样就可以将字符串数组中的每个字符串都输出出来。

0