hi master
sir i have string array how i add that array in vector
i tried flowing code
but not give me restul
String[] jlf = {"Muhammad","Fahim","Aamir"};
vector.addElement(jlf);
plsease give me idea how i add array in vector
thank
aamir
Printable View
hi master
sir i have string array how i add that array in vector
i tried flowing code
but not give me restul
String[] jlf = {"Muhammad","Fahim","Aamir"};
vector.addElement(jlf);
plsease give me idea how i add array in vector
thank
aamir
That you are doing should work ... as long as you are creating a vector object and then adding your String array to that vector object, such as:
Vector myVector = new Vector();
myVector.addElement(jlf);
This is a place where you could use "Generics" in declaring your vector as holding elements which are arrays of Strings, to allow the compiler to do type checking for you when adding elements to the vector:
Vector<String[]> myVector = new Vector<String[]>();
thank for your reply
hi master
sir how use vector in combobox
or how i fill the combobox with vector
thank
aamir
Amir needs to copy the contents of an array to a vector!
String[] strs = new String[]{"a", "b"};
Vector v = new Vector();
v.addAll(Arrays.asList(strs));
Now the vector is filled with strings "a" and "b".
JList list = new JList(v); // will work