I want to define a Vector that is of type of a Vector of String.
I did it:
Vector <Vector<String>> musicNames=new Vector <Vector<String>>();
My problem is when I want to enter a Vector to 'albumNames'.
If I don't know how many vectors I want to add to the first Vector(I mean musicNames), or if there are a lot of Vector I want to add to the first Vector, what should I do?
For example for adding 1000 Vectors to 'musicNames' I cannot 'new' another Vector 1000 times and add it to 'musicNames' each time.
I thought and used a loop. but I think it is not correct:
boolean t=true;
while (true)
{
Vector<String> musics=new Vector<String>();
String s1=UserIn.readString();
String s2=UserIn.readString();
String s3=UserIn.readString();
String s4=UserIn.readString();
//user should enter four string
musics.addElement(s1);
musics.addElement(s2);
musics.addElement(s3);
musics.addElement(s4);
//add four String to vector 'albumNames'
musicNames.addElement(musics);
System.out.println("If you want to enter musics again enter #");
System.out.println("If you don't want, enter $");
char myChar=UserIn.readChar();
if (myChar=='$')
t=false;
if (t==false)
break;
}
Is it correct? Can anyone help me?
I am very new in programming. so please, please, please explain in simple way for me if you can.
thanks.

New Topic/Question
Reply




MultiQuote





|