public static MyType mtOrders;
public static MyType mtCustomers;
public static MyType mtItems;
public static MyType mtGroups;
public static MyType mtDelieverAddresses;
public static MyType mtVendors;
public static MyType mtOrderItems;
public static MyType mtPrims;
public final static MyType[] xTable = {mtCustomers, mtGroups, mtItems, mtOrders,
mtDelieverAddresses, mtVendors, mtOrderItems, mtPrims};
for (int i = 0; i < xTables.length; i++) {
xTable[i] = new MyType();
}
执行后xTable
的元素被初始化,但是mtOrders
......mtPrims
为空!
我明白为什么会这样,但我想不出我是如何初始化循环中的对象的。
我不想这样做:
mtOrders = new MyType();
mtCustomers = new MyType();
...
mtPrims = new MyType();