如何在Java中声明数组变量?
您可以像声明变量一样声明数组-
int myArray[];
您可以使用new关键字像对象一样创建数组-
myArray = new int[5];
您可以通过使用索引逐一为所有元素分配值来初始化数组-
myArray [0] = 101; myArray [1] = 102;
您可以使用索引值访问数组元素-
System.out.println("The first element of the array is: " + myArray [0]);
System.out.println("The first element of the array is: " + myArray [1]);
Alternatively, you can create and initialize an array using the flower braces ({ }):
Int [] myArray = {10, 20, 30, 40, 50}热门推荐
10 留学申请成功祝福语简短
11 婚礼远方嘉宾祝福语简短
12 鼠年元旦生日祝福语简短
13 森林消防家属祝福语简短
14 迎接新年祝福语简短霸气
15 送米的祝福语简短
16 升学祝福语简短100个
17 爱心大叔生日祝福语简短
18 小孩生日送花祝福语简短