Java 数组打印
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]
}
}
拼命敲