如何在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 50多岁生日简短祝福语
13 安徽疫情祝福语简短英语
14 农民朋友发财祝福语简短
15 对生活祝福语简短精辟
16 搬家词简短祝福语朋友
17 女神结婚快乐祝福语简短
18 文学短句祝福语大全简短