1

The below code is working, but its looking odd to me, is there any better way to this.

var res:scala.collection.mutable.LinkedHashMap[String,scala.collection.immutable.Map[String,String]]=??
var arList = new ArrayList[String]()
res.keySet.map(arList.add(_))
//here res key set changed so i want to reassign the list by new keySet
res=??                                                        //updated
arList.clear
res.keySet.map(arList.add(_))

its looking very odd that to call the .clear on arList

lbalazscs
  • 17,474
  • 7
  • 42
  • 50
Govind Singh
  • 15,282
  • 14
  • 72
  • 106

1 Answers1

5

You can use default JavaConverters.

  import scala.collection.JavaConverters._
  val list = new java.util.ArrayList(res.keySet.asJavaCollection)

I didn't get why do you need to do clear, is it some requirement that you pass ArrayList once and update it's content later?

Eugene Zhulenev
  • 9,714
  • 2
  • 30
  • 40