我有以下数据结构:
dataModel.training = {ArrayList@4748} size = 4
0 = {HashMap@4784} size = 6
0 = {HashMap$HashMapEntry@4790} "controller" -> "Training01"
key = {String@4796} "controller"
value = {String@4797} "Training01"
1 = {HashMap$HashMapEntry@4791} "description" -> "0101_0"
2 = {HashMap$HashMapEntry@4792} "subset" -> "0,62"
3 = {HashMap$HashMapEntry@4793} "table" -> "voctrain"
4 = {HashMap$HashMapEntry@4794} "template" -> "resthai"
5 = {HashMap$HashMapEntry@4795} "form" -> "Training01"
1 = {HashMap@4785} size = 9
2 = {HashMap@4786} size = 9
3 = {HashMap@4787} size = 7
如何在ArrayList的第一个条目(dataModel.training [0])中获取键“controller”的值?
答案 0 :(得分:1)
Map map =dataModel.training.get(0)// this return Hashmap at 0th Index
map.get("controller");// returns 'training'
如果你想在一个声明中这样做
dataModel.training.get(0).get("controller");
同样可以推广所有其他键和值
希望这有帮助!
祝你好运!