You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
LArray can create arrays with more than 2G(2^31) entries. 2^31 -1 (2G) is the limitation of the default Java/Scala array size, because these arrays use 32-bit signed integer (int) as indexes. LArray uses long type indexes of 64-bit signed integers to resolve this limitation. For example, the entire human genome data (3GB) can be stored in LArray. LArray can be released immediately from the memory.
int型の配列を使うときは以下のようにします。これは問題ないですね。 int[] array = new int[10]; // (1) しかし自分で定義したクラスのオブジェクトの配列を使う場合は、同じようにしてもうまくいきません。 class NewClass{ int a; int b; } public static void main(String[] args) { NewClass[] dim = new NewClass[3]; // (2) dim[0].a = 1; dim[0].b = 10; dim[1].a = 2; dim[1].b = 20; dim[2].a = 3; dim[2].b = 30; } (1)と同様に(2)と書いたのに、これを実行するとNull Pointer Exceptionが発生してしまいます。 調べたところ、(2)は、オブジェクトを入れ
Javaのソースで、たまに「ArrayListを使っているけど、代入する要素数は決まっている」というのを見かけます。 こういうのを見ると、「要素数が決まっているなら、可変のもの(ArrayList)じゃなくて固定のもの(配列)を使った方が速くてメモリ使用量も少なくて済むんじゃないのかな」といつも思います。 でも、よく考えたら試していない・・・。 そこで実験。 「配列に代入」するのと「ArrayListに追加」するのは、どちらが速い・軽い・うまい!? - ソースは最後に添付します。 先に結果だけ。 配列とArrayListでは、 初期容量を指定しなければ、配列の方が3倍速い 初期容量を指定しても、配列の方が2倍速い。 (ただ、10,000,000万回ループしてちょっとの差が出るぐらい。どちらでも十分に速い) 配列とArrayListでは、 初期容量を指定しなければ、ArrayListの方がメ
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く