Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create an empty immutable Scala map in Java?

This should be an obvious one but I've not yet found an elegant solution. For various reasons, I need to create an immutable Scala map (scala.collection.immutable.Map from Scala 2.10), but I can only write Java code. How do I do this?

like image 476
SoftMemes Avatar asked Jan 16 '13 18:01

SoftMemes


People also ask

How do I make an empty map in Scala?

The empty() method is utilized to make the map empty. Return Type: It returns an empty map.

How do you set an empty map?

The emptyMap() method is used to get the empty map (immutable). This map is serializable.

Is Scala map immutable?

By default, Scala uses the immutable Map. If you want to use the mutable Map, you'll have to import scala. collection.


1 Answers

Wild guess - here goes nothing:

scala.collection.immutable.Map$.MODULE$.<…, …>empty()
like image 172
Wilfred Springer Avatar answered Sep 28 '22 08:09

Wilfred Springer