1
我想將我的用戶定義的對象添加到鏈接列表中,但是每次添加時,信息都會被複制。如何將用戶定義的對象添加到LinkedList?
public class Videostore(){
public LinkedList<Video> videoList = new LinkedList<>();
public Videostore(){
addVideo("a");
addVideo("b");
addVideo("c");
}
private void addVideo(String o){
Video vid = new Video(o);
videoList.add(vid);
}
}
public class Video {
public static Object title;
public static boolean isRent;
public Video(String t){
title = t;
isRent = false;
}
public static void setisRent(boolean bool){
isRent = bool;
}
public String toString(){
return title.toString();
}
}
當Video Store初始化時,videoList只有「c」的內部。我需要它有一個b和c。