这里用到了java反射获取对象的属性值
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
public class TestSomeTool
{
@Test
public void testMain()
{
List<Object> objs = new ArrayList<Object>();
for (int i = 0; i < 10; i++)
{
TestObj testObj = new TestObj();
testObj.setStrA("A" + i);
if (i < 4)
{
testObj.setStrB("B1");
}
else if (i < 6)
{
testObj.setStrB("B2");
}
else
{
testObj.setStrB("B3");
}
if (i < 2)
{
testObj.setStrC("C1");
}
else if (i < 5)
{
testObj.setStrC("C2");
}
else
{
testObj.setStrC("C3");
}
objs.add(testObj);
}
//以"strB"作为整合值
System.out.println("以‘strB’作为整合值");
printDoubleList(getDoubleDeckList(objs, "strB"));
//以"strC"作为整合值
System.out.println(