Scala
Seq("a","b","c")
Java
@SafeVarargs
public static <T> Seq<T> Seq(T... values) {
Seq<T> seq = JavaConverters.collectionAsScalaIterableConverter(Arrays.asList(values)).asScala().toSeq();
return seq;
}
échantillon
Opération équivalente à Scala *** Seq (1,2,3) *** en Java
import java.util.Arrays;
import scala.collection.JavaConverters;
import scala.collection.Seq;
public class SeqInJava {
public static void main(String[] args) {
Seq<Integer> seqInJava = Seq(1, 2, 3);
}
@SafeVarargs
public static <T> Seq<T> Seq(T... values) {
Seq<T> seq = JavaConverters.collectionAsScalaIterableConverter(Arrays.asList(values)).asScala().toSeq();
return seq;
}
}
JavaConverters.seqAsJavaList(Seq(1, 2, 3))
échantillon
import java.util.Arrays;
import java.util.List;
import scala.collection.JavaConverters;
import scala.collection.Seq;
public class SeqToList {
public static void main(String[] args) {
List<Integer> list = JavaConverters.seqAsJavaList(Seq(1, 2, 3));
System.out.println(list);
}
@SafeVarargs
public static <T> Seq<T> Seq(T... values) {
Seq<T> seq = JavaConverters.collectionAsScalaIterableConverter(Arrays.asList(values)).asScala().toSeq();
return seq;
}
}
Recommended Posts