Map map = new LinkedHashMap();
这样写与
Map map = new LinkedHashMap();有什么区别,,,在Eclipse都能编译通过,,而且在进行迭代时,显示也没有问题?
想知道这样的区别到底是什么,,,因为看到所有的视频都是按照第一种写法
你写的这两句不是一样吗?你创建了一个Map的引用map 然后通过new LinkedHashMap创建了一个LinkedHashMap的对象,引用指向了这个对象,迭代看你采用什么迭代方式
你写的这两句不是一样吗???
你写的就是new 后面多了一个空格,按照格式后面写的是正规的,前面的是偷懒写的吧,你格式化后就会变成后面一种
楼主想说的是Map map = new HashMap();和Map map = new LinkedHashMap();
这两句是一样的吧,效果是一样的啊。
http://blog.csdn.net/zhangsunxiang/article/details/42235671
复制下来也错了 - - 重发一遍
Mapmap = new LinkedHashMap();
Map map = new LinkedHashMap();
上面一种如果键值存入非String类型的编译器会报错
The method put(String, String) in the type Map is not applicable for the arguments (String, int)
下面一种键值可以存入多种类型的值
建议去看下泛型
估计没用代码块的原因楼主自己理解吧
Map map = new LinkedHashMap();
Map map = new LinkedHashMap();
上面一种如果键值存入非String类型的编译器会报错
The method put(String, String) in the type Map is not applicable for the arguments (String, int)
下面一种键值可以存入多种类型的值
建议去看下泛型