Resize an array

Hi,

Is it possible to resize an array of objects ? I create an array of 10000 objets. But I need ,after more calculations , only 8000 objects. Is it possible to resize the original array without create another array and copy the original in the new array ?

Thank you for your help

Marcel

[312 byte] By [braydunesa] at [2007-9-30 1:23:40]
# 1

No, you cannot resize arrays in java.

The simplest thing to do is use one of the List implementations. ArrayList and LinkedList both provide

the appearence of resizable structures. (ArrayList contains an array which it automatically resizes for you

(by copying) which LinkedList is inherently dynamic in size (but slow to perform indexed get operations

on)

matfud

matfuda at 2007-7-16 6:00:28 > top of Java-index,Other Topics,Algorithms...
# 2
If you want to use plain arrays then the System.arrayCopy method is useful for copying the data from your large array to a smaller one.matfud
matfuda at 2007-7-16 6:00:28 > top of Java-index,Other Topics,Algorithms...