| Author |
Vector of vector...
|
lokesh rajarathnam
Ranch Hand
Joined: May 17, 2007
Posts: 35
|
|
Hi... I need to know how to add an vector to another vector. Issue... The text file contains N number of lines and each line contains 12 number of words. I need to store an 12 words(one line)in vector after that the vector will be stored into another new vector. I will able to do split the line into words... any help please...
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
The add(E o) method will do this. Why have you decided to use a Vector? Normally there isn't a good reason to use this class. [ July 17, 2008: Message edited by: Paul Sturrock ]
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32694
|
|
Why aren't you using a String[][]? As Paul has suggested, ArrayList<String> and ArrayList<ArrayList<String>> are better implementations.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
That's never a good solution. Use ArrayList<List<String>>. That can still store ArrayList<String>, but also LinkedList<String> if needed. The declaration and initialization would be <blockquote>code: <pre name="code" class="core">List<List<String>> list = new ArrayList<List<String>>(); list.add(new ArrayList<String>());</pre> </blockquote>
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
 |
|
|
subject: Vector of vector...
|
|
|