数组的默认值_JAVA_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > JAVA > 数组的默认值

数组的默认值

 2010/9/19 23:11:35  jiaguwen123  http://jiaguwen123.javaeye.com  我要评论(0)
  • 摘要:publicclassTest{staticintis[]=newint[5];staticString[]arrs=newString[5];staticObject[]objs=newObject[5];staticBoolean[]bo=newBoolean[5];publicstaticvoidmain(String[]args){intn=1;for(inti:is){System.out.print("is["+n+"]="+i+";");n++;}System.out
  • 标签:数组 默认值

?public class Test {
???? static int is[] = new int[5];??
???? static String[] arrs = new String[5];??
???? static Object[] objs = new Object[5];
???? static Boolean[] bo = new Boolean[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 -= 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++;??
???????? }
???????? System.out.println();??
???????? n -= 5;// n=n-5;?
???????? for(Boolean boo :bo){
???????????? System.out.print("bo[" + n + "] = " + boo + "; ");??
???????????? n++;
???????? }
??
???? }??
?}

?

====Result结果:

is[1] = 0; is[2] = 0; is[3] = 0; is[4] = 0; is[5] = 0;
arrs[1] = null; arrs[2] = null; arrs[3] = null; arrs[4] = null; arrs[5] = null;
objs[1] = null; objs[2] = null; objs[3] = null; objs[4] = null; objs[5] = null;
bo[1] = null; bo[2] = null; bo[3] = null; bo[4] = null; bo[5] = null;

发表评论
用户名: 匿名