Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/367.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用varargs时出现非常奇怪的编译错误_Java_Enums_Compiler Errors - Fatal编程技术网

Java 使用varargs时出现非常奇怪的编译错误

Java 使用varargs时出现非常奇怪的编译错误,java,enums,compiler-errors,Java,Enums,Compiler Errors,我正在为JVM中的所有操作码编写枚举。它还不完整,到目前为止看起来是这样的: public enum Opcode { NOP(), ACONST_NULL(), ICONST_M1(), ICONST_0(), ICONST_1(), // a zillion more of these JSR_W(); private Opcode(Class<? extends Argument> args...) {

我正在为JVM中的所有操作码编写枚举。它还不完整,到目前为止看起来是这样的:

public enum Opcode {
    NOP(),
    ACONST_NULL(),
    ICONST_M1(),
    ICONST_0(),
    ICONST_1(),
    // a zillion more of these
    JSR_W();

    private Opcode(Class<? extends Argument> args...) {
    }
}
公共枚举操作码{
否(),
ACONST_NULL(),
ICONST_M1(),
ICONST_0(),
ICONST_1(),
//还有无数这样的
JSR_W();

私有操作码(ClassThe
符号在参数类型上,而不是在参数名称上,如下所示

private Opcode(Class<? extends Argument>... args) {
}
其中
LastFormatParameter
的格式为

LastFormalParameter:
    VariableModifiersopt Type... VariableDeclaratorId
    FormalParameter

..
在参数类型声明之后。

符号在参数类型上,而不是在参数名称上,如下所示

private Opcode(Class<? extends Argument>... args) {
}
其中
LastFormatParameter
的格式为

LastFormalParameter:
    VariableModifiersopt Type... VariableDeclaratorId
    FormalParameter

位于参数类型声明之后。

非常感谢您帮助我解决了这一点健忘症。我将在9分钟后接受。非常感谢您帮助我解决了这一点健忘症。我将在9分钟后接受。您不需要空的
()
。@PeterLawrey如果我省略它,它会尝试调用没有参数的构造函数吗?只有在你有参数的情况下,否则它会调用你有空数组的构造函数。你不需要空的
()
在你的常量上。@PeterLawrey如果我省略它,它会尝试调用没有参数的构造函数吗?只有在你有参数的情况下,否则它会调用你有空数组的构造函数。