以下代码给我一个编译错误:
public static Function<int[], Stream<Tuple2<Formatter, List<Object>>>> acquisitionColors = (col) -> Seq.of(
Tuple.tuple(Formatter.COLOR,
Seq.of(
Seq.of(col).toList(),
Seq.of(
Seq.of("Stop", "Stoq", null, "red").toList(),
Seq.of("Learning", "Learninh", null, "gray").toList(),
Seq.of("Stop", "Stoq", null, "red").toList(),
Seq.of("Reduce", "Reducf", null, "orange").toList(),
Seq.of("Keep", "Keeq", null, "green").toList(),
Seq.of("Increase", "Increasf", null, "blue").toList()
).toList()
).toList()
)
);
Wrong 2nd argument type. Found: 'java.util.List<java.util.List<? extends java.lang.Object>>', required: 'java.util.List<java.lang.Object>'
Inspection info:
tuple (Formatter,java.uti.List<java.lang.Object>) in Tuple cannot be applied
to (Formatter,java.util.List<java.util.List<? extends java.lanq.Object>>)
但是,如果我用 a 包装该列表Collections.singletonList,它会起作用:
public static Function<int[], Stream<Tuple2<Formatter, List<Object>>>> acquisitionColors = (col) -> Seq.of(
Tuple.tuple(Formatter.COLOR,
Collections.singletonList(
...
).toList())
)
);
为什么会发生这种情况?
PIPIONE
Cats萌萌
摇曳的蔷薇
相关分类