title: Java FlatMapFunction in Spark: error: is not abstract and does not override abstract method call(String) in FlatMapFunction
body: <p>I was trying to run the first <a href="http://spark.apache.org/examples.html" rel="noreferrer">example</a>.</p>
  
  <p>The source code is:</p>
  
  <pre><code>/*keyWordCount.java */
              import org.apache.spark.*;
              import org.apache.spark.api.java.*;
              import org.apache.spark.api.java.function.*;
              import org.apache.spark.rdd.*;
              import org.apache.spark.api.java.JavaRDD;
              import java.util.*;
  
              public class keyWordCount {
  
                  public static void main(String[] args) {
                      SparkConf conf = new SparkConf().setAppName("keyWordCount");
                      JavaSparkContext sc = new JavaSparkContext(conf);
                      JavaRDD&lt;String&gt; textFile = sc.textFile("output");
                      JavaRDD&lt;String&gt; dictFile = sc.textFile("keyword");
                      JavaRDD&lt;String&gt; words = textFile.flatMap(new FlatMapFunction&lt;String, String&gt;() {
                          @Override public Iterable&lt;String&gt; call(String s) { return Arrays.asList(s.split(" ")); }
                      });
                  }
              }
  </code></pre>
  
  <p>When I compile using mvn compile package, the following error keep showing up: </p>
  
  <blockquote>
    <p>[ERROR] COMPILATION ERROR :  [INFO]
    ------------------------------------------------------------- [ERROR] /home/cyberliem/TestSpark/src/main/java/keyWordCount.java:[16,81]
    error:  is not abstract and does not
    override abstract method call(String) in FlatMapFunction</p>
    
    <p>[ERROR]
    /home/cyberliem/TestSpark/src/main/java/keyWordCount.java:[17,39]
    error: call(String) in  cannot implement
    call(T) in FlatMapFunction</p>
    
    <p>[ERROR] 
        T extends Object declared in interface FlatMapFunction
        R extends Object declared in interface FlatMapFunction /home/cyberliem/TestSpark/src/main/java/keyWordCount.java:[17,5]
    error: method does not override or implement a method from a supertype</p>
  </blockquote>
  
  <p>I'm not sure how to fix this, can anyone give me an ideal why it goes wrong?</p>