扫描二维码下载沐宇APP

沐宇

微信扫码使用沐宇小程序

沐宇

java字符串数组如何输出

扬州沐宇科技
2023-11-30 15:49:25
Java

使用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

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

扫码添加客服微信