首页 > 解决方案 > Minecraft Spigot 与 ImmutableList 有问题

问题描述

在代码末尾这个错误是什么问题?尝试了许多修复,但没有人帮助 https://i.stack.imgur.com/jwosT.png

标签: java

解决方案


return (List<String>) ImmutableList.of();

这样做的问题是ImmutableList.of()在应用强制转换之前确定了类型。

ImmutableList.of()在那种情况下的类型是ImmutableList<Object>。一个ImmutableList<Object>不是一个ImmutableList<String>

我很惊讶您在这里需要任何类型提示:

return ImmutableList.of();

推荐阅读