java List<String[] > table 赋值 和取值问题

2025-06-21 22:17:23
推荐回答(1个)
回答1:

首先,纠正一下,List table,这个类型为List,名字为table,所以List并没有setName这个方法(除非你自己重写List),至于{[xx,yy],[qq,ww],[ee,rr]} 这种赋值方式,对于List来说是不存在的(除非你自己重写List)。
如果我没有理解错你的意思的话,你是想保存一个数据表的数据
这样的话可以这样设计
编写一个类,例如:Tabel类
这个Table类包含两个属性
private String name;
private Map property;
name属性代表数据表的名字
property属性代表数据表的column以及对应数据;
这样就可以通过Table 这个类实现你所提及的赋取值
Table table = new Table();
赋值:
table.setName("my_table");
Map map = new HashMap();
map.put("r",new Object[]{"rr"});
map.put("q",new Object[]{"qq"});
......
table.setProperty(map);
取值:
String name = table.getName();
String[] r = table.getProperty().get("r");
String[] q = table.getProperty().get("q");
......
不知道有没有理解错误你的意思