【发布时间】:2016-03-17 20:32:57
【问题描述】:
我创建了一个类Entry,看起来像这样
public class Entry<S,E>{
S Item1;
E Item2;
Entry(S s, E e){
this.Item1=s;
this.Item2=e;
}
}
我想做一个这种类型的ArrayList。它应该是什么样子?
如何添加item1 但保留item2 null 以备后用?
(换句话说,用item1s 填充数组并为item2s 填充null,数组看起来像 [1]Item1,null , [2]Item1, null 等)
【问题讨论】:
标签: java class generics arraylist data-structures