Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / April 2004

Tip: Looking for answers? Try searching our database.

Array Question

Thread view: 
JavaJunkie - 03 Apr 2004 06:42 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.