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 )

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值