摘要:
public class News implements Comparable { private int id; //新闻编号 private String title; //新闻标题 @Override public String toString() { return "新闻 [编号=" + id + ", 标题=" + title + "]"; } publi... 阅读全文
摘要:
public class ListTest { public static void main(String[] args) { //创建几个新闻对象 News news1=new News(1, "新闻1"); News news2=new News(2, "新闻2"); News news3=new News(3, "新闻3"); //创建一个List集合 ... 阅读全文
摘要:
List 接口存储一组不唯一(可以重复),有序(插入顺序)的对象 01. ArrayList实现了长度可变的数组,在内存中分配连续的空间。遍历元素和随机访问元素的效率比较高 通过看ArrayList的源码得知: /** * Constructs an empty list with an initial capacity of ten. 构造一个初... 阅读全文