java处理json数组_用Java处理数组

java处理json数组

If a program needs to work with a number of values of the same data type, you could declare a variable for each number. For example, a program that displays lottery numbers:

如果程序需要使用多个相同数据类型的值,则可以为每个数字声明一个变量 。 例如,显示彩票号码的程序:

int lotteryNumber1 = 16; 
int lotteryNumber2 = 32; 
int lotteryNumber3 = 12; 
int lotteryNumber4 = 23; 
int lotteryNumber5 = 33; int lotteryNumber6 

A more elegant way of dealing with values which can be grouped together is to use an array. An array is a container that holds a fixed number of values of a data type. In the above example, the lottery numbers could be grouped together in an int array:

处理可以分组在一起的值的一种更优雅的方法是使用数组。 数组是保存固定数量的数据类型值的容器。 在上面的示例中,彩票号码可以组合为一个int数组:


int[] lotteryNumbers = {16,32,12,23,33,20};

Think of an array as a row of boxes. The number of boxes in the array cannot change. Each box can hold a value as long as it is of the same data type as the values contained within the other boxes. You can look inside a box to see what value it contains or replace the contents of the box with another value. When talking about arrays, the boxes are called elements.

将数组想像成一排盒子。 阵列中的盒子数不能更改。 每个框都可以保存一个值,只要它与其他框中包含的值具有相同的数据类型即可。 您可以查看框内的内容以查看其包含的值,也可以将框的内容替换为另一个值。 当谈论数组时,这些盒子称为元素。

声明和初始化数组 ( Declaring and Initializing an Array )

你可能感兴趣的:(java,数据结构,python,编程语言,c++)