Jessica,

Vector is a legacy class. You should now use ArrayList class. ArrayList stores 
elements in an underlying array. The system will default the size for you. The 
system then manages the underlying array. If you add elements to the ArrayList 
and the underlying array is full the system creates a new larger underlying 
array and copies the old underlying array to the new underlying array. There 
are some slight performance issue in adding and deleting from the middle of the 
list. If you have a rough guess of the size the ArrayList should be, set it 
slightly larger. Too large and you waste space to small and the system will 
have to create a new array that is larger to handle the ArrayList expanding. 
Size of ArrayList is a concern if performance is an issue.

The lessons on Java Collections Framework. -> Exercise 2: Build and run 
applications that use "List" Collection objects (30 minutes)->
Build and run an application that uses ArrayList 

These lessons show how to work with ArrayList. If you are working with legacy 
code that requires Vector class I think it is similar to ArrayList.

Keith



________________________________
From: Jessica Sun <[email protected]>
To: [email protected]
Sent: Wednesday, February 25, 2009 7:04:34 AM
Subject: [java programming] Pls Share ur experience with Java Vector


Dear all,
 
 
Discussions about Vector in JAVA
 
vector is like an array, but it grows as necessary to allow you to add as many 
elements as you like.  
So it becomes very handy when you program something with unknown number. 
 
Here are my questions
 
If I want to vector instead of an array , the type of array will be double, how 
should I implement it. See example below
 
double  Jarray  [] = new double [100] ;
double  KTarray [] = new double [100] ;
double m_dHigh, m_dStep, Jrange;
int Ni;
….
for( Ni=0; Jrange<=m_dHigh+0.00000001; Ni++){   
                Jarray[Ni]=Jrange;   
              ( Some methods here)
                KTarray[Ni]=KTT;
               Jrange=Jrange+m_dStep;
    }
 
In this code I want to use Vector Jarray instead of Jarray[] and KTarray[]; 
 
Please if you have time come up with your ideas, and any literature of how to 
use Vector are welcome!
 
Thanks in advance
 
Best Regards
Js  (a new user of java )
 
 
 
 


      
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to