• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

convert hashmap <string, anytype > to hashMap<string, object>

 
zuje lal
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can somebody help me to convert any type of "values" , might be integer,string .. To object
I want to keep the key as same and want to convert the value as object
thanks
zuje
 
Rob Spoor
Sheriff
Pie
Posts: 20546
56
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anything that is not a primitive is already an Object. Therefore, Map<String,Integer> is a Map<? extends String,? extends Object>, and you can use it in the putAll method:

Also, most Map implementation classes have a constructor that takes a Map<? extends K,? extends V> so it's even shorter for only one map:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic