You have not provided much details of what you actually need. But from the sample code you provided I assume this is what you are trying to achieve.
To understand clearly Instead of object I used a class Holder with a single String to store the letter.
I have used Lambda expression to print the list
public class TestMain2 {
public static void main(String[] args) {
Holder a = new Holder("A");
Holder b = new Holder("B");
Holder c = new Holder("C");
Holder d = new Holder("D");
Holder e = new Holder("E");
Holder f = new Holder("F");
Holder[] childHolder1 = { a, b };
Holder[] childHolder2 = { c, d };
Holder[] childHolder3 = { e, f };
List<Holder[]> holderParentList = new ArrayList<Holder[]>();
holderParentList.add(childHolder1);
holderParentList.add(childHolder2);
holderParentList.add(childHolder3);
holderParentList.forEach( child->{
System.out.println(child[0]+","+child[1]);
});
}
}
class Holder {
private String a;
public Holder(String a) {
super();
this.a = a;
}
public String getA() {
return a;
}
public void setA(String a) {
this.a = a;
}
@Override
public String toString() {
return a;
}
}