}
结果是:[李三 性别 :男 年龄是 :25岁 学号是24,
张三 性别 :男 年龄是 :25岁 学号是25,
李四 性别 :男 年龄是 :23岁 学号是23]
hashset可以添加,整体打印。但是不能查找,因为他是无序排列的
public static void main(String[] args) {
LinkedList<Student> linklist=new LinkedList<Student>();
Student studentA=new Student("李四","23",23,'男');
Student studentB=new Student("李三","24",25,'男');
Student studentC=new Student("张三","25",25,'男');
linklist.addLast(studentA);
linklist.addLast(studentB);
linklist.addLast(studentC);
Student stFirst=linklist.removeFirst();
System.out.println(stFirst);
System.out.println("已销户");
stFirst=linklist.removeFirst();
System.out.println(stFirst);
System.out.println("已销户");
Student stLast=linklist.removeLast();
System.out.println(stLast);
}
结果是:李四 性别 :男 年龄是 :23岁 学号是23
已销户
李三 性别 :男 年龄是 :25岁 学号是24
已销户
张三 性别 :男 年龄是 :25岁 学号是25
linklist也可以执行添加,能删除,从头,从尾都行,因为他的内部是整齐排列的