java数组的定义

class ArrayDome 
{
	public static void main(String[] args) 
	{
		//元素类型[] 数组名   创建一个 元素类型[元素个数或数组长度]
		/*
			需要一个容器但是不清楚容器的具体数据
		
		int[] arr = new int[3];
		arr[0] = 6;
		System.out.println(arr[0]);
		*/



		//不需要定义数组长度  下面既定义了内容 有定义了长度
		/*
			需要一个容器 储存已知道的具体数据
		
		int[] arr = new int[]{12,51,12,11};
		*/

		int[] arr = {12,51,12,11};  //静态化初始方式
	}
}


posted on 2019-02-09 10:31  该用户不在服务区  阅读(124)  评论(0)    收藏  举报

导航