使用特定类名时出现 JShell 错误“意外类型”
我只是在玩JShell,似乎定义然后定义不起作用。但是使用不同的类名(如 和 )确实有效。class Z{}
var z = new Z()
class X
class A
当然,我一定错过了一些明显的东西...?
| Welcome to JShell -- Version 14.0.1
| For an introduction type: /help intro
jshell> class X{}
| created class X
jshell> class Z{}
| created class Z
jshell> var x = new X()
x ==> X@26a1ab54
| created variable x : X
jshell> var z = new Z()
| Error:
| unexpected type
| required: class
| found: type parameter Z
| var z = new Z();
| ^
jshell> class A{}
| created class A
jshell> var a = new A()
a ==> A@2ef1e4fa
| created variable a : A