简体   繁体   中英

Storing different types of arguments in HashMap

I am using following code:

public boolean  initialSetupDone;
public Currency defaultCurrency;
public String   userId;

final String  kProfileSetupDoneKey  = "kProfileSetupDone";
final String  kDefaultCurrencyKey   = "kDefaultCurrency";
final String  kUserIdKey            = "kUserIdKey";

String values are the keys while others are the values.

Please tell me how can i store these values as HashMap . I have tried to do it with Dictionary , but can't find any good way to do it.

How can i do that

Best Regards

Like this, but is usually not a good idea to mix types in a map:

Map<String, Object> map = new HashMap<String, Object>();
map.put(kProfileSetupDoneKey  , initialSetupDone);
// etc...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM