# Vector<vector> loop thru

• 11-20-2009, 05:10 PM
ocean
Vector<vector> loop thru
SOLVED

Evening, new problem that makes my hair grey, if i have a

Code:

Vector<vector> rowDataIn = new Vector<vector>

And i loop it thru with.

Code:

Iterator iterator = rowDataIn.iterator();
while (iterator.hasNext()){
done = iterator.next();
}

It just loop thru the first one. Leaving the Object done with the result [1, 2] and not 1 2 as i would like. How can this be solved?
• 11-20-2009, 09:01 PM
JosAH
What is your 'vector' class? (lowercase 'v')

kind regards,

Jos
• 11-20-2009, 09:21 PM
ocean
Sorry just a misspell when i posted, it should be Vector<Vector> rowDataIn = new Vector<Vector>
• 11-20-2009, 09:26 PM
ocean
Do you understand what my problem is? my bad English makes it hard for me to explain.
• 11-21-2009, 09:45 AM
JosAH
Quote:

Originally Posted by ocean
Do you understand what my problem is? my bad English makes it hard for me to explain.

Your English is fine but what exactly is your problem? The outer vector contains vectors, I understood that, but what do you want to do with them?

kind regards,

Jos
• 11-21-2009, 10:06 AM
ocean
Im sending the data to a file, and i want the format data,data,data. And not [data,data,data]. I need someway too loop the Object done.

if i write out the vector before any loop it looks like --> [[data,data,data]]

I Use Iterator and after the loop it looks like this --> [data,data,data]

I Need another loop so it looks like this --> data,data,data

My problem is that after the first loop my Vector has turned into an Object and i cant use Iterator on it.
• 11-21-2009, 11:36 AM
ocean
I realise now that i have posted wrong. It should be as follow.

Code:

Vector<Vector> v = new Vector<Vector>
Vector<String> s = new Vector<String>

Now itś correct, how do i loop thrue the v Vector so the result will be
One Two Three.

And not [One,Two,Three]
• 11-21-2009, 12:43 PM
ocean
Solved it! Thanks anyway.
• 11-21-2009, 12:54 PM
JosAH
Quote:

Originally Posted by ocean
I realise now that i have posted wrong. It should be as follow.

Code:

Vector<Vector> v = new Vector<Vector>
Vector<String> s = new Vector<String>

Now itś correct, how do i loop thrue the v Vector so the result will be
One Two Three.

And not [One,Two,Three]

I don't know what you have in mind exactly but when I print vector v I get [[One, Two, Three]] as I expected (a vector with one element which is a vector containing three elements).

kind regards,

Jos
• 11-21-2009, 02:13 PM
ocean
What i have in mind is to save the userinput from JTable into a file as data;data;data. wich it now does. But as I solved 1 problem next is just arund the corner.

It saves it all in one row. Somehow i need to count columns and add a \n at the end.

Anyone has experience at saving from JTable to File, And Read it back from File to JTable? And that mabey could give me some advice ow this is best done.
• 11-21-2009, 02:37 PM
Fubarable
Hm, serialize the data might be an option. Have you gone through the Serialization tutorial at the Sun tutorials?
• 11-21-2009, 03:17 PM
ocean
Hmm indeed, I think your rigth. Will need more reading tho. Thankś for pointning me there.:)