import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
/**
* LinkedHashMap按放入顺序迭代输出.
*/
public class LinkedHashMapTest {
public static void main(String[] args) {
Map maps = new LinkedHashMap();
maps.put("葫芦娃技能表:", "按出现先后顺序");
maps.put("蛇妖", "");
maps.put("大娃", "大力士,变大,巨人");
maps.put("二娃", "千里眼,顺风耳,机灵鬼 ");
maps.put("三娃", "铜头铁臂,钢筋铁骨,刀枪不入");
maps.put("四娃", "火功,电击,用于攻击 ");
maps.put("五娃", "吸水,吐水,用于攻击 ");
maps.put("六娃", "隐身术,来无影去无踪 ");
maps.put("七娃", "宝葫芦,可以吸妖怪");
maps.put("金刚葫芦娃", "所有葫芦娃技能");
for(Iterator it = maps.entrySet().iterator();it.hasNext();){
Entry entry = (Entry)it.next();
if(!"".equals(entry.getValue())){
System.out.println(entry.getKey() + "\t" + entry.getValue());
}
}
}
}
控制台输出结果: