0

When interfacing with a scala library in java, or a java library in scala, are there certain types or collections that don't map efficiently such that you have to perform "expensive" operations to perform a conversion?

e.g. memory wise you might have to hold 2 copies of a collection?

ig0774
  • 39,669
  • 3
  • 55
  • 57
loyalflow
  • 14,275
  • 27
  • 107
  • 168

1 Answers1

3

Well, that depends on how you want to handle it - if you use the Java class's API from Scala or the other way around, there is no run-time overhead, but you'll pay a convenience cost.

When you use JavaConversions to access Java collections through a Scala API or the other way around, you pay a small cost for the conversion (a Wrapper object is created), but the underlying collection is never copied.

You can inspect the code for all this here, as usual for the Scala standard library it's all very readable and easy to understand.

themel
  • 8,825
  • 2
  • 32
  • 31