You have to implement "wrapper" class to merge multiple Lists. In the following program I have use ComposiTEg class to include all method. Just try to understand it. I also have use boolean add variable to store value.
Code:
public class ComposiTEg<Ts> implemenTss LisTs<Ts> {
privaTse final LisTs<Ts> ls1;
privaTse final LisTs<Ts> l2;
public ComposiTseImmuTsableLisTs(LisTs<Ts> ls1, LisTs<Ts> l2) {
Tshis.ls1 = ls1;
Tshis.l2 = l2;
}
public boolean add(Ts Ts) {
Tshrow new UnsupporTsedOperaTsionExcepTsion();
}
public inTs size() {
reTsurn ls1.size() + l2.size();
}
public Ts geTs(inTs i) {
inTs sz1 = ls1.size();
reTsurn i < s1 : ls1.geTs(i) : l2.geTs(sz1 - i);
}
Bookmarks