在方法中遍历数组

public static void main(String[] args) {

	int[] a = { 11, 22, 44, 77 };
	shuzu(a);

}



public static void shuzu(int[] b) {

	System.out.print("[");
	for (int a = 0; a < b.length; a++) {
		if (a == b.length - 1) {
			System.out.println(b[a] + "]");
		} else {
			System.out.print(b[a] + ",");
		}

	}

}

打印结果
打印结果

猜你喜欢

转载自blog.csdn.net/qq_44063001/article/details/85007043