I have 1 Scala Array containing Strings and 1 Java Util List containing Strings. I want to check if value of one Array is in the other List, and set a flag accordingly.
def getFlag(JavaList, scalaArray): Boolean = {
val res = JavaList.toArray.filter(x => scalaArray.contains(x))
if (res.isEmpty)
false
else
true
}
the contains doesn't seem to be working. It always shows the size as 0 even when there should be a matching string and I'm not sure why.
How would I fix this or are there any other better methods of doing this? I am trying to get more familiar with Scala any help is appreciated thank you
JavaListandscalaArrayprior to filtering? And possiblyJavaList.toArray? Thanks.res, then check if it's empty in an if statement, and return true or false manually. You could just returnres.isEmptyor write the whole thing out in one line