标签:初始化 man package 静态初始化 示例 src new lazy ack
//静态初始化:创建 + 赋值
int[] a = {1,2,3};
Man[] mans = {new Man(1,1),new Man(2,2)};
//动态初始化 : 包含默认初始化
int[] a = new int[2];
a[0]=1;
a[1]=2;
package com.wenjian.array;
public class ArrayDemo02 {
public static void main(String[] args) {
//静态初始化:创建 + 赋值
int[] a = {1, 2, 3, 4, 5, 6, 7, 8};
System.out.println(a[0]);
Man[] mans = {new Man(),new Man()};
//动态初始化 : 包含默认初始化
int[] b = new int[10];
b[0] = 10;
b[1] = 10;
System.out.println(b[0]);
System.out.println(b[1]);
System.out.println(b[2]); //数组若未赋值,默认值是0
}
}
输出:
1
10
10
0
进程已结束,退出代码 0
标签:初始化 man package 静态初始化 示例 src new lazy ack
原文地址:https://www.cnblogs.com/function123/p/13409217.html