-3

How can i do to convert scala map to java HashMap?

My scala map below:

val map = Map((KEY_CONDITION, keyCondition), (RANGE_CONDITION, rangeCondition))

My java code below:

method(HashMap<String, Object> hashmap){
//do something
}

Thanks

om-nom-nom
  • 62,329
  • 13
  • 183
  • 228
guestUser
  • 1
  • 2
  • Downvoted as the internet is plentiful of [*using scala collections in java*](https://www.google.com/search?q=using+scala+collections+in+java) answers, including stackoverflow (no prior research was shown) – om-nom-nom Feb 10 '14 at 18:29
  • Seconding the downvote, for the same reason – Kevin Wright Feb 10 '14 at 19:26

1 Answers1

1

There's a large variety of converters in scala.collection.JavaConverters with implicit conversions in scala.collection.JavaConversions. Once you load these implicits you should be able to pass the scala Maps directly to the java methods as if they were Java Maps

Andrew Cassidy
  • 2,940
  • 1
  • 22
  • 46
Randall Schulz
  • 26,420
  • 4
  • 61
  • 81
  • Hi Andrew, Thank you! I'm not a scala guy and still puzzled, could you please give some example :) – Jack Apr 16 '15 at 23:36