Using scala to call java.util.Hashtable # put

I have an unexpected problem with an old school hash table. What's going on here?

Welcome to Scala version 2.8.0.final (Java HotSpot(TM) Client VM, Java 1.6.0_21).
Type in expressions to have them evaluated.
Type :help for more information.

scala> import com.ibm.mq._                 
import com.ibm.mq._

scala> MQEnvironment.properties                                                    
res1: java.util.Hashtable[_, _] = {}

scala> res1.put("transport", "MQSeries")
<console>:10: error: type mismatch;
 found   : java.lang.String("transport")
 required: ?0 where type ?0
       res1.put("transport", "MQSeries")
            ^

PS, the question still stands as it is, but I have an unpleasant workaround:

scala> new java.util.Hashtable[String, String]
res10: java.util.Hashtable[String,String] = {}

scala> res10.put("transport", "MQSeries")      
res11: String = null

scala> MQEnvironment.properties = res10

scala> MQEnvironment.properties        
res13: java.util.Hashtable[_, _] = {transport=MQSeries}
+3
source share
1 answer

properties API , Java-. java.util.HashTable[_, _] , ( ) ?0, . "" Java - , Java Scala, , API.

+4

Source: https://habr.com/ru/post/1761827/


All Articles