spock单测[]被认为是ArrayList怎么办?
如果是这么写,执行会报错,传递数组时确实会被认为是 ArrayList,如果你需要传递一个真正的数组,可以 使用显式的数组声明
下面是报错信息:
![image spock单测[]被认为是ArrayList怎么办?_数组](https://file.cfanz.cn/uploads/png/2024/10/30/13/48a47eUP57.png)
![image spock单测[]被认为是ArrayList怎么办?_spock_02](https://file.cfanz.cn/uploads/png/2024/10/30/13/ZI04915cF3.png)
需要在数组的时候 后面加个 as 显示声明下. 代码从["疑似色情"]改成 ["疑似色情"] as String[]
就不会报错了.
![image spock单测[]被认为是ArrayList怎么办?_数组_03](https://file.cfanz.cn/uploads/png/2024/10/30/13/ZCdGZ75e88.png)
spock单测[]被认为是ArrayList怎么办?
阅读 16
2024-10-30
如果是这么写,执行会报错,传递数组时确实会被认为是 ArrayList,如果你需要传递一个真正的数组,可以 使用显式的数组声明
下面是报错信息:
![image spock单测[]被认为是ArrayList怎么办?_数组](https://file.cfanz.cn/uploads/png/2024/10/30/13/48a47eUP57.png)
![image spock单测[]被认为是ArrayList怎么办?_spock_02](https://file.cfanz.cn/uploads/png/2024/10/30/13/ZI04915cF3.png)
需要在数组的时候 后面加个 as 显示声明下. 代码从["疑似色情"]改成 ["疑似色情"] as String[]
就不会报错了.
![image spock单测[]被认为是ArrayList怎么办?_数组_03](https://file.cfanz.cn/uploads/png/2024/10/30/13/ZCdGZ75e88.png)
相关推荐
精彩评论(0)