java怎么输出一个数组里的数据

在Java中,可以使用循环来输出数组中的数据。以下是一个示例代码:

public class Main {
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5};
        
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }
}

运行上面的代码,将会输出数组arr中的数据:

1
2
3
4
5
阅读剩余
THE END