title: Spark Java - Why Tuple2 can not be argument of function in map?
body: <p>I am new to Spark. I have written the following Java code</p>
  
  <pre><code>JavaPairRDD&lt;Detection, Detection&gt; allCombinations = currentLevelNodes.cartesian(nextLevelNodes);
  
  allCombinations.map(new Function&lt;Tuple2&lt;Detection, Detection&gt;, Segment&gt;(){
    public Segment call(Tuple2&lt;Detection, Detection&gt; combination){
       Segment segment = new Segment();
       Detection a = combination._1();
       Detection b = combination._2();
       segment.distance = Math.sqrt( Math.pow((a.x)-(b.x), 2) + Math.pow((a.y)-(b.y), 2) );
  
       return segment;
    }
  });
  </code></pre>
  
  <p><br/>
  The IDE(Eclipse Neon) shows up the following message</p>
  
  <pre><code>Multiple markers at this line
  - The method map(Function&lt;Tuple2&lt;Detection,Detection&gt;,R&gt;) in the type 
   AbstractJavaRDDLike&lt;Tuple2&lt;Detection,Detection&gt;,JavaPairRDD&lt;Detection,Detection&gt;&gt; is not applicable for the arguments (new 
   Function&lt;Tuple2&lt;Detection,Detection&gt;,Segment&gt;(){})
  - The type new Function&lt;Tuple2&lt;Detection,Detection&gt;,Segment&gt;(){} must implement the inherited abstract method 
   Function&lt;Tuple2&lt;Detection,Detection&gt;,Segment&gt;.apply(Tuple2&lt;Detection,Detection&gt;)
  </code></pre>
  
  <p><br></p>
  
  <p>How do I solve this problem ?</p>