【发布时间】:2021-08-08 09:03:22
【问题描述】:
内容是否应该已经以ByteBuffers 的形式提供,从它们创建数组的费用是多少?
import java.nio.ByteBuffer;
public class Main
{
public static void main(String[] args) {
ByteBuffer buf1 = ByteBuffer.allocate(666); /*(0)*/
ByteBuffer buf2 = ByteBuffer.allocate(666); /*(0)*/
ByteBuffer buf3 = ByteBuffer.allocate(666); /*(0)*/
ByteBuffer arr[] = new ByteBuffer[]{buf1,buf2,buf3}; /* (1) */
}
}
数组创建不应该取决于缓冲区的大小,对吧?
【问题讨论】:
-
您在寻找什么类型的答案?
-
我认为这仅取决于缓冲区的数量
-
Java 索引 references 中的对象数组。所以如果你问内存中数组的大小是否取决于缓冲区的大小,那么答案是否定的。