MAP数组
来源:互联网 发布:高仿鞋淘宝 编辑:程序博客网 时间:2024/06/05 16:03
Map[] maps=new Map[len];
JSONArray jsonArray=new JSONArray();
for(int i=0;i<len;i++){
maps[i]= new HashMap();
JSONObject jsonObject=new JSONObject();
if(taskIds[i]!=null || taskIds[i]!=""){
maps[i].put("userId", userId);
maps[i].put("Task_ID", taskIds[i]);
int node_id=Integer.parseInt(NodeIds[i]);
maps[i].put("Node_ID", node_id);
maps[i].put("taskName", taskNames[i]);
maps[i].put("operationID", operationID);
maps[i].put("refreshUrl", refreshUrl);
maps[i].put("openTabId", openTabIds[i]);
maps[i].put("opinion", opinion);
jsonObject.put("taskId", taskIds[i]);
jsonObject.put("nodeId", node_id);
jsonArray.put(i,jsonObject);
}
JSONArray jsonArray=new JSONArray();
for(int i=0;i<len;i++){
maps[i]= new HashMap();
JSONObject jsonObject=new JSONObject();
if(taskIds[i]!=null || taskIds[i]!=""){
maps[i].put("userId", userId);
maps[i].put("Task_ID", taskIds[i]);
int node_id=Integer.parseInt(NodeIds[i]);
maps[i].put("Node_ID", node_id);
maps[i].put("taskName", taskNames[i]);
maps[i].put("operationID", operationID);
maps[i].put("refreshUrl", refreshUrl);
maps[i].put("openTabId", openTabIds[i]);
maps[i].put("opinion", opinion);
jsonObject.put("taskId", taskIds[i]);
jsonObject.put("nodeId", node_id);
jsonArray.put(i,jsonObject);
}
}
在以上代码中需要使用MAP数组,而改数组的每一项也是一个map。之前的操作是在for循环中每次定义一个map,然后将他put到MAP数组中,后来证实这种做法不可取。最后该改进为上面的写法,之前想MAP[i]中去put所需要的数据。
- MAP数组
- map转换为数组:
- 关联数组Map<...>
- Map.get()得到数组
- 数组的map方法
- 遍历map数组
- js数组map方法
- 数组函数map
- ES5 数组方法map
- 数组 Map 使用小结
- 数组 集合 map
- 模拟js数组方法map()
- Map使用之关联数组
- 用数组实现Map功能
- Map获取key的数组
- java,list,map,set数组
- Map实现快速增补数组
- velocity map list 数组操作
- 关于《C语言深度剖析》之编译器的bug问题
- js获取项目根路径
- php中session过期时间设置
- list 转换 map
- 单独hibernate 生成表
- MAP数组
- Linux下core文件产生的一些注意问题
- MYSQL数据库导入SQL文件出现乱码如何解决
- Linux下minicom的配置和使用方法
- C# 实现保留两位小数的方法
- Android多线程:Looper和HandlerThread
- 加载大图片OOM问题
- adsl-setup
- Python(4) 调用linux shell command