import java.util.Vector;
class Song
{
public String s1=null;
public String s2=null;
public String s3=null;
public String s4=null;
public boolean b=false;
public String s6=null;
public String s7=null;
public Song(String s1,String s2,String s3,String s4,boolean b,String s6,String s7)
{
this.s1=s1;
this.s2=s2;
this.s3=s3;
this.s4=s4;
this.b=b;
this.s6=s6;
this.s7=s7;
}
}
public class TestVector {
public static void main(String[] args){
Vector v = new Vector();
String s = new String("1");
v.add(s);
System.out.println(v.toString());
String s0 = new String("12");
v.add(s0);
System.out.println(v.toString());
Vector vector = new Vector();
Song s1 = new Song("Pachchai Nirame", "2:15", "Tamil Pop", "Alai Payuthey (2000)",false, "TPS001", ";
vector.add(s1);
Song s2 = new Song("A Dios Le Pido", "1:50", "Latin Pop", "Juanes : Un Dia Normal/1", false, "SPS003", ";
vector.add(s2);
Song s3 = new Song("Bombay (Children of Combodia)", "2:38", "Jazz", "Fred Andersen Quartet/1", false, "WCS002", ";
vector.add(s3);
System.out.println(vector.toString());
}
}
此段代码是在百度上见到的,我稍作修改,添加了一个类Song,结果反映出vector作为向量的存储.
阅读(1026) | 评论(0) | 转发(0) |