如何在HashMap(Android)中存储值?

如何在HashMap(Android)中存储值?,第1张

概述我在soap消息中工作,使用SAXparser检索存储在ArrayList中的值(来自Webservice)和ArrayList工作正常,但是我想存储在HashMap中,因为使用key来识别每个名称都有一定的SystemId,请任何人帮帮我 ThanksI tried the code: public class SitesList { private ArrayL 我在soap消息中工作,使用SAXparser检索存储在ArrayList中的值(来自Webservice)和ArrayList工作正常,但是我想存储在HashMap中,因为使用key来识别每个名称都有一定的SystemID,请任何人帮帮我

ThanksI trIEd the code:    public class SitesList     {    private ArrayList<String> name = new ArrayList<String>();private ArrayList<String> systemID = new ArrayList<String>();    //Map <String,String> map =  new HashMap<String,String>();    public ArrayList<String>  getname(){    return name;}public voID setname(String nameString)   {    this.name.add(nameString);    System.out.println("name  "+ name); }public ArrayList<String>  getSystemID(){    return systemID;}public voID setSystemID(String systemIDString)   {    this.systemID.add(systemIDString);        System.out.println("systemID  "+systemID);  }
解决方法 你可以这样存储

你是arrayList的名字

private ArrayList<String> name = new ArrayList<String>();

和HashMap一样

HashMap<String,ArrayList<String>>h = new HashMap<String,ArrayList<String>>();

你可以像这样存储你的arrayList

h.put("name",name);
总结

以上是内存溢出为你收集整理的如何在HashMap(Android)中存储值?全部内容,希望文章能够帮你解决如何在HashMap(Android)中存储值?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1128943.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-30
下一篇2022-05-30

发表评论

登录后才能评论

评论列表(0条)

    保存