This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Vector of vector... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Vector of vector..." Watch "Vector of vector..." New topic

Vector of vector...

lokesh rajarathnam
Ranch Hand

Joined: May 17, 2007
Posts: 35

I need to know how to add an vector to another vector.

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

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

Joined: Oct 13, 2005
Posts: 38020
Why aren't you using a String[][]?

As Paul has suggested, ArrayList<String> and ArrayList<ArrayList<String>> are better implementations.
Rob Spoor

Joined: Oct 27, 2005
Posts: 19654

Originally posted by Campbell Ritchie:

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
<pre name="code" class="core">List<List<String>> list = new ArrayList<List<String>>();
list.add(new ArrayList<String>());

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: Vector of vector...
Similar Threads
Writing Big Vector to file.
I want to iterate all elements in vector and store it in another vector..?
Sorting a vector
String Parsing