try 使用Java 22的功能.下面是正在编译的代码.
Employee emp= new Employee(2, 3);
if (emp instanceof Employee(int x, __)) {
System.out.println("Employee is a position, x = " + x);
}
Compilation exception is: Syntax error, insert "RecordStructurePattern" to complete RecordPattern
即使以下面的方式使用上面的代码,那么它的工作
Employee emp= new Employee(2, 3);
if (emp instanceof Employee(int x, int __)) {
System.out.println("Employee is a position, x = " + x);
}
这里的员工是一个记录.我正在使用Java 22.
无法理解这里出了什么问题