两者之间有什么区别(如果有的话)
Lists.transform(list, function)
和
FluentIterable.from(list).transform(function).toList()
?
最佳答案
Lists.transform
返回一个 List
,它是原始 List
的 View 。如果您在原始列表中添加或删除项目, View 也会发生变化。
FluentIterable.from(list).transform
类似地返回原始列表的转换 View ,不过作为 FluentIterable
而不是 List
>。但是,当您对其调用 toList()
时,您会返回一个 ImmutableList
,如果原始列表发生变化(或者永远不会发生变化),该列表将不会发生变化。这很重要)。
关于java - Guava - Lists.transform(..., ...) 和 FluentIterable.from(...).transform(...) 之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25897767/