I've been trying to find a way to resize an array after it has been instantiated, but haven't had any luck. I was wondering if anyone could help me.
Example:
double[][] blurry = new double[50][3];
now sometime later in my code - I realize that the array cannot hold all of my information - I really needed it to be
double[][] blurry = new double[5000][3];
- is there anyway to do this on the fly - altering the already existing array - rather than just creating a new instance of an array?
Thanks:]
JavaJunkie - 03 Apr 2004 07:46 GMT
I've been trying to find a way to resize an array after it has been instanciated, but haven't had any luck.
Example:
double[][] dblArray = new double[50][3];
now sometime later in my code - I realize that the array cannot hold all of my information - I really needed it to be
double[][] dblArray = new double[5000][3];
- is there anyway to do this on the fly - altering the already existing array - rather than just creating a new instance of an array?

Signature
"Life is too short, to say, I will do it later or tomorrow. Live life to the fullest, Learn, Prosper, and most important of all, Love!"
Connie A
I've been trying to find a way to resize an array after it has been instantiated, but haven't had any luck. I was wondering if anyone could help me.
Example:
double[][] blurry = new double[50][3];
now sometime later in my code - I realize that the array cannot hold all of my information - I really needed it to be
double[][] blurry = new double[5000][3];
- is there anyway to do this on the fly - altering the already existing array - rather than just creating a new instance of an array?
Thanks:]
Mark Haase - 03 Apr 2004 08:08 GMT
> - is there anyway to do this on the fly - altering the already existing array
> - rather than just creating a new instance of an array?
Nope, Java arrays are fixed in size. If you need a larger one you'll
have to create it and copy over all the information from the old one. Or
consider using a Vector -- although there's no guarantee that it does
anything more efficient.
|\/| /| |2 |<
mehaase(at)sas(dot)upenn(dot)edu
JavaJunkie - 03 Apr 2004 20:36 GMT
Mark, thanks for the information. Will check out the link.
JJ
> > - is there anyway to do this on the fly - altering the already existing array
> > - rather than just creating a new instance of an array?
[quoted text clipped - 6 lines]
> |\/| /| |2 |<
> mehaase(at)sas(dot)upenn(dot)edu