51,396
社区成员




List<Byte> bList = new ArrayList<Byte>();
bList.add((byte)1);
bList.add((byte)2);
bList.add((byte)3);
bList.add((byte)4);
System.out.println("hello");
for (int i = 0; i < bList.size(); i++) {
System.out.println("--->>"+bList.get(i));
}
byte[] bArr = new byte[bList.size()];
//如何将bList赋给bArr,C#中bList.CopyTo(bArr),在Java中该怎么处理
List<Byte> bList = new ArrayList<Byte>();
bList.add((byte)1);
bList.add((byte)2);
bList.add((byte)3);
bList.add((byte)4);
System.out.println("hello");
for (int i = 0; i < bList.size(); i++) {
System.out.println("--->>"+bList.get(i));
}
Byte [] arrs = new Byte[bList.size()];
//将集合bList转换成arrs数组。
bList.toArray(arrs);
byte[] bArr = new byte[bList.size()];
int i = 0;
for (byte b : bList) {
bArr[i++] = b;
}
byte[] bArr = new byte[bList.size()];
for(int i = 0; i < bList.size(); i++)
{
bArr[i]=bList.get(i);
}
Byte[] bArr = new Byte[bList.size()];
bList.toArray(bArr);
System.out.println(Arrays.toString(bArr));
Byte[] bArr = new Byte[bList.size()];
bArr=bList.toArray(new Byte[0]);
System.out.println(Arrays.asList(bArr));