java 获取数组值_java获取数组值的数量

我已经有了以下代码

public class Qn3

{

static BigDecimal[] accbal= new BigDecimal[20];

private static Integer[] accnums = new Integer[5];

public static void main(String[] args)

{

int count;

accnums = {1,2} //i cant add this line of code as well, what is wrong?

while(accnums.length < 5)

{

count = accnums.number_of_filled_up_indexes

//this is not actual code i know

//do this as the number of values in the array are less than 5

break;

}

//do this as number of values in the array are more than 5

}

}我必须使用此代码没有改变这是一个要求,所以请不要建议使用arraylist等(我知道其他数组类型和方法)

问题在于,因为我已经声明accnums只能包含5个值,而这些值是预定义的。

我试图执行一个检查,不是空的,如果都是空的。要做到这一点,我试过这个,但这是给我5 p(预定义的整数数组值不是我想要的)。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值