Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-13-2007, 10:40 PM
Member
 
Join Date: Jul 2007
Posts: 44
Rep Power: 0
susan is on a distinguished road
Default How i add string array in vector
I have string array how i add that array in vector
I tried flowing code but not give me result
Code:
String[] jlf = {"Muhammad","Fahim","Aamir"};

vector.addElement(jlf);

Please give me idea how i add array in vector

Thanks
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 07-16-2007, 06:44 AM
Member
 
Join Date: Jul 2007
Posts: 2
Rep Power: 0
akaruppa is on a distinguished road
Default
Hi,
You need to use vector.addAll(Collection c) to achieve this.
In order to convert array to Collection, u can use Arrays.asList(jlf)...
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 02-10-2009, 09:51 PM
Member
 
Join Date: Feb 2009
Posts: 3
Rep Power: 0
javier gonzalez is on a distinguished road
Default Maybe this help
Vector <String[]> vector =new Vector();

String[] jlf = {"Muhammad","Fahim","Aamir"};

vector.add(jlf);

String [] leer =null;

for (int i = 0; i < vector.size(); i++)
{
leer= (String[]) (vector.get(i));
for (int a=0;a<leer.length ;a++){
System.out.println(leer[a]);
}
}

*i'm searching a better way to acces the array inside the vector but this work very well by now.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 02-10-2009, 10:00 PM
Senior Member
 
Join Date: Sep 2008
Posts: 564
Rep Power: 2
emceenugget is on a distinguished road
Default
confused, do you have a vector of an array of strings? or do you want the array of strings to be converted to a vector?
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 02-11-2009, 06:41 AM
Member
 
Join Date: Feb 2009
Posts: 3
Rep Power: 0
javier gonzalez is on a distinguished road
Default
I have a vector of string.
well i'm doing in the line
Vector <String[]> vector =new Vector();
is creating a Vector and each element in the vector will be an array of String, it will have the size and properties of the type String.

if a do Vector vector = new Vector(); every element in the vector will be a Object insted of a String. Both can be use.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 02-11-2009, 07:19 AM
Senior Member
 
Join Date: Jan 2009
Posts: 360
Rep Power: 2
toadaly is on a distinguished road
Default
FYI, if you do this..

Code:
Vector<String[]> vector = new Vector<String[]>();
instead of this...

Code:
Vector<String[]> vector = new Vector();
then you can do this ...

Code:
leer = vector.get(i);
instead of this...

Code:
leer = (String[]) vector.get(i);
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 02-12-2009, 11:41 AM
Senior Member
 
Join Date: Jun 2008
Posts: 1,393
Rep Power: 3
masijade is on a distinguished road
Default
Originally Posted by artonlinehome View Post
Vector <String[]> vector =new Vector();

String[] jlf = {"Muhammad","Fahim","Aamir"};

vector.add(jlf);

String [] leer =null;

for (int i = 0; i < vector.size(); i++)
{
leer= (String[]) (vector.get(i));
for (int a=0;a<leer.length ;a++){
System.out.println(leer[a]);
}
}
Why did you simply copy and repost the unformatted code from above?
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 02-12-2009, 02:32 PM
CJSLMAN's Avatar
Moderator
 
Join Date: Oct 2008
Location: Mexico
Posts: 1,159
Rep Power: 3
CJSLMAN is on a distinguished road
Default 20 is the limit...
Two things:
1) He's not going to answer you
2) I think he's trying to fill up the forum with nonsense posts so he can make to the 20 posts limit.

CJSL
__________________
Chris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert a vector to a string array orchid New To Java 4 02-24-2010 03:31 AM
Converting an Array to a Vector Java Tip java.lang 0 04-14-2008 09:44 PM
Array or Vector ravian New To Java 2 11-18-2007 07:19 PM
I can't seem to pass the value of a string variable into a string array mathias Java Applets 1 08-03-2007 11:52 AM
array vs Vector paty New To Java 1 08-02-2007 08:07 PM


All times are GMT +2. The time now is 03:33 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org