package notebook; import java.util.LinkedHashMap; public class notebook {     public static void main(String[] args) {         LinkedHashMap<Integer,String> notebook=new LinkedHashMap<Integer,String>();         //存储记录         notebook.put(1, "Happy");         notebook.put(2, "New");         notebook.put(3, "Year");         notebook.put(4, "Everyone");         //获取存储记录的数量         int num=notebook.size();         System.out.println("存储记录的数量为:"+num);         //查看某一条记录         System.out.println("第1条记录为:"+notebook.get(1));         //列出所有记录         for(int i=0;i<num;i++)         {             System.out.println(notebook.get(i));         }         //删除某一条记录         notebook.remove(2);         //列出所有记录         for(int i=0;i<num;i++)         {             System.out.println(notebook.get(i));         }    } }
点赞 评论

相关推荐

牛客网
牛客企业服务