How to add element into ArrayList in HashMap

前端 未结 5 757
予麋鹿
予麋鹿 2020-12-15 05:22

How to add element into ArrayList in HashMap?

    HashMap> Items = new HashMap>();
         


        
5条回答
  •  离开以前
    2020-12-15 06:17

    #i'm also maintaining insertion order here
    Map d=new LinkedHashMap<>();
    for( int i=0; i<2; i++)
    {
    int id=s.nextInt();
    ArrayList al=new ArrayList<>();
    al.add(s.next());  //name
    al.add(s.next());  //category
    al.add(s.nextInt()); //fee
    d.put(id, al);
     }
    

提交回复
热议问题