---
title: "数组的默认值"
author: "413899327"
date: "2010-07-10T09:51:53Z"
tags: []
categories: ["编程语言"]
slug: "untitled"
draft: false
lastmod: "2010-07-10T20:49:15Z"
id: 709619
url: "https://rogerfederer.iteye.com/blog/709619"
---

```java
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;