【发布时间】:2014-06-25 04:25:05
【问题描述】:
我正在尝试将我的用户定义对象添加到链接列表中,但是每次添加时,信息都会重复。
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();
}
}
当视频存储初始化时,videoList 里面只有“c”。我需要它有一个 b 和 c。
【问题讨论】:
标签: java object linked-list user-defined-functions