ITeye博客

数组的默认值

413899327 · 2010-07-10 09:51 · java总结 · 编程语言 · Markdown

package test1;

public class ArrayDefaultValue {

	static int is[] = new int[5];
	static String[] arrs = new String[5];
	static Object[] objs = new Object[5];

	public static void main(String[] args) {
		int n = 1;
		for (int i : is) {
			System.out.print("is[" + n + "] = " + i + "; ");
			n++;
		}
		System.out.println(n + "\n");
		n -= 5;// n=n-5;
		for (String arr : arrs) {
			System.out.print("arrs[" + n + "] = " + arr + "; ");
			n++;
		}
		System.out.println();
		n -= 5;// n=n-5;
		for (Object obj : objs) {

			System.out.print("objs[" + n + "] = " + obj + "; ");
			n++;
		}

	}
}

========================

result: is = 0; is = 0; is = 0; is = 0; is = 0; 6 arrs = null; arrs = null; arrs = null; arrs = null; arrs = null; objs = null; objs = null; objs = null; objs = null; objs = null;

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。