I am designing a Rinex file reader class in Java and this is my first project in Java. I need to store data into an array or vector. I am reading the data from the file related to the time the data occurs. At first I tried to use an array but I do not know the size of the array ahead of time. Is there anyway to make an array change size as it grows in a loop? For example in Matlab you could initialize the array to be an array of zeros. Or do I have to use vectors to do this? I also have this problem with a 3D array that I was creating. How would I use vectors to create a 3D array? Thanks!!
kbradley 0 Newbie Poster
Recommended Answers
Jump to Postimport java.util.*; class Test { public static void main(String[] args) { ArrayList al = new ArrayList(); al.add("one"); al.add("two"); } }
Notice how there's no set size anywhere.
Jump to PostHi everyone,
Vectors are evil, look up the ArrayList if you want an array that grows as needed.
Narue what makes you say that vectors are evil?
Richard West
*****************************************************
All 7 Replies
jwenting 1,905 duckman Team Colleague
Narue 5,707 Bad Cop Team Colleague
kbradley 0 Newbie Poster
server_crash 64 Postaholic
jwenting 1,905 duckman Team Colleague
freesoft_2000 9 Practically a Master Poster
jwenting 1,905 duckman Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.