简体   繁体   English

Java中的Scala方法覆盖

[英]Scala method override in Java

I have a method in Scala with below syntax . 我在Scala中有一个方法,语法如下。 I want to override this method in a java sub class. 我想在java子类中重写此方法。 I am not sure what will be the equivalent syntax in Java for this method . 我不确定这种方法在Java中的等效语法是什么。

def createRecord(rdd: RDD[(String, Array[(String, Int)])])

the below is the java equivalent of the scala method createRecord. 下面是scala方法createRecord的java等价物。 The reason why Int in scala is converted to an Object in Java is provided here 这里提供了将 scala中的Int转换为Java中的Object的原因

 import org.apache.spark.rdd.RDD;
 import scala.Tuple2;
 public void createRecord(RDD<Tuple2<String, Tuple2<String, Object>[]>> rdd) {

 }

You can use The Java API RDD of spark as well and Integer (a class ) here as: 你也可以使用spark的Java API RDD和Integer(一个类):

import scala.Tuple2;
import org.apache.spark.api.java.JavaRDD

 public void method(JavaRDD<Tuple2<String,Tuple2<String,Integer>[]>> rdd)
  {
      return the equivalent implementation
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM