对象数组
来源:互联网 发布:复旦大数据学院研究生 编辑:程序博客网 时间:2024/05/19 08:38
声明一个对象数组
HashMap[]map1 = new HashMap[10];
for(int i = 0;i<10;i++){
map1[i].put("touxiang", R.drawable.touxiang);
map1[i].put("nicheng", "荒城旧日");
map1[i].put("content", "fweggwgwgwf"
+" gwgw");
map1[i].put("img", R.drawable.dongtai);
}
以上代码会报空指针异常
应该为每一项申请一个空间,应该改为
HashMap[]map1 = new HashMap[10];
for(int i = 0;i<10;i++){
map1[i] = new HashMap();
map1[i].put("touxiang", R.drawable.touxiang);
map1[i].put("nicheng", "荒城旧日");
map1[i].put("content", "fweggwgwgwf"
+" gwgw");
map1[i].put("img", R.drawable.dongtai);
}
0 0
- 对象数组
- 对象数组
- 对象数组
- 对象数组
- 数组对象
- 对象数组
- 数组对象
- 对象数组
- 对象数组
- 对象数组
- 对象数组
- 对象数组
- 数组对象
- 对象数组
- 对象数组
- 对象数组
- 对象数组
- 对象数组
- OSX安装meteor时候CURL报SSL证书无效,curl: (60) SSL certificate problem: Invalid certificate chain
- nodemcu开发之旅(1)
- 高德地图-AndroidStadio-No implementation found for long com.autonavi.amap.mapcore.MapCore.nativeNewInsta
- java设计模式——工厂模式
- php数组合并两个数组(一个数组做键名,另一个做值)
- 对象数组
- ios 获取当前屏幕的ViewController
- 为tableView中的一组cell添加边框
- 【图像处理】图像几何变换基础(非弹性变换下如何计算旋转矩阵)
- [华为机试]扑克牌大小
- 从耗子叔vim攻略上新学到的以及遗忘但又捡起来的VIM技巧
- 勾股定理每日一证 1
- 基于ZooKeeper的分布式配置管理系统
- 纯新手本地搭建ECShop环境