Muhammad Umar
Muhammad Umar

Reputation: 11782

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

Upvotes: 0

Views: 1680

Answers (1)

Guillaume Polet
Guillaume Polet

Reputation: 47607

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...

Upvotes: 2

Related Questions