Newbie Newbie - 10 months ago 49
Scala Question

How to convert java stream to scala streams?

I am new to scala I am trying to understand the streams. Can I some tell me the difference between jsva 8 streams filter and streams in scala ?

How do I convert this in scala ?

For example if I want to convert this to scala do I need to use to Stream or Stream[] ?

itemList.getIds() is

Map<String, List<Ids>>

.filter(entry -> validate(entry.getValue(), time))



Here is a similar sample

Assuming a data structure and validate function is defined

val myMap = Map(1 -> "Value1",2 -> "Value2")
val time = System.currentTimeMillis

def validate(str:String, time:Long) = true

Then a straight translate of your code could simply be

myMap.filter(entry => validate(entry._2, time)).map(_._1).take(1)