作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个在 Java 中定义的方法,例如:
void foo(int x, Thing... things)
override def foo(x: Int, things: Thing*)
override def foo(x: Int, things: Array[Thing])
<repeated...>
但我不知道那是什么。
> compile
[info] Compiling 1 Scala source to [...]/target/scala-2.10/classes...
[error] [...]/src/main/scala/Translator.scala:41: class MyMethodVisitor needs to be abstract, since method visitTableSwitchInsn is not defined
[error] (Note that org.objectweb.asm.Label* does not match <repeated...>[org.objectweb.asm.Label])
[error] class MyMethodVisitor extends MethodVisitor (Opcodes.ASM4) {
[error] ^
visitTableSwitchInsn
只是缺少主体,但错误表明问题在于 varargs 参数的类型。
最佳答案
java :
package rrs.scribble;
public
class VA1
{
public int va1(int... ints) {
return ints.length;
}
}
package rrs.scribble
class VA1S
extends VA1
{
override
def va1(ints: Int*): Int =
ints.length * 2
}
> ~compile
[info] Compiling 1 Scala source and 1 Java source to …/scribble/target/scala-2.10/classes...
[success] Total time: 4 s, completed Jan 15, 2013 3:48:14 PM
1. Waiting for source changes... (press enter to interrupt)
关于scala - 如何在 Scala 中覆盖 Java varargs 方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14348631/
我是一名优秀的程序员,十分优秀!