[英]How to instantiate a Java generic inner class in Scala?
// Parent.java
public class Parent {
public class Tuple3<X, Y, Z> {
public final X x;
public final Y y;
public final Z z;
public Tuple3(X x, Y y, Z z) {
this.x = x;
this.y = y;
this.z = z;
}
public X _1() {
return x;
}
public Y _2() {
return y;
}
public Z _3() {
return z;
}
}
....
}
Then if I want to instantiate a Tuple3<String,String,Boolean>
object in scala how do I write? 然后,如果我想在scala中实例化
Tuple3<String,String,Boolean>
对象,我该如何编写?
Essentially the same way you'd do it in Java. 基本上与您在Java中使用的方式相同。
val outer = new Parent
val inner = new outer.Tuple3("hi", "there", true)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.