Convert Scala expression to Java 1.8

Viewed 326

I'm trying to convert this Scala expression to Java:

val corpus: RDD[String] = sc.wholeTextFiles("docs/*.md").map(_._2)

This is what I have in Java:

RDD<String> corpus = sc.wholeTextFiles("docs/*.md").map(a -> a._2);

But I get an error on a._2:.

Bad return type in lambda expression: String cannot be converted to R

If I go to the "super" method, this is what I see:

package org.apache.spark.api.java.function;

import java.io.Serializable;

public interface Function<T1, R> extends Serializable {
        R call(T1 var1) throws Exception;
}
2 Answers
Related