最近想要写个table表,可以设定我自己定义public class XXX每个member的default值,如下:
public class AAA{
byte A1;
List<BBB> UUTList = new ArrayList<BBB>();
}
public class BBB {
byte B1;
boolean B2
String B3;
byte[] B4;
}
//table
BBB BBBGroup[][] = {
// B1 B2 B3 B4
{ (byte) 0x01, true, "Japan", null},
{ (byte) 0x02, false, "Korea", null},
{ (byte) 0x03, true, "Taiwan", null},
{ (byte) 0x04, false, "USA", null},
{ (byte) 0x05, true, "China", null},
{} // end element, null
};
这样的写法eclipse会回我:
"Type mismatch: cannot convert from byte to BBB"
"Type mismatch: cannot convert from boolean to BBB"
"Type mismatch: cannot convert from String to BBB"
.....
看的出来它把array里每个成员都认成BBB这个class,但若不这样写,JAVA要如何像C一样写一个table就可以maintain structure中每个member的default value呢? 请板上有经验的前辈提点一下!感激不尽!