- import java.util.Arrays;
- public class test {public static void main(String[] args) {int[] arr = { 1, 2, 3, 4, 5 };// for 循环 for (int i = 0; i < arr.length; i++) {System.out.print(arr[i]); //12345} // for each 循环 for (int a : arr) {System.err.print(a); //12345} // Arrays 类的 toString 方法 System.out.println(Arrays.toString(arr)); //[1,2,3,4,5]}}
来源: http://www.bubuko.com/infodetail-2753677.html