gpt4 book ai didi

java - EnumSet 的不可变版本

转载 作者:太空狗 更新时间:2023-10-29 23:03:51 25 4
gpt4 key购买 nike

我找不到 Immutable EnumSet 的版本.两个问题:

我可以在普通的 Guava ImmutableSet 中使用枚举吗?

如果可以的话,使用 ImmutableSet 而不是 EnumSet 有哪些优点/缺点?

最佳答案

你在找Sets.immutableEnumSet吗( Guava )也许?

Returns an immutable set instance containing the given enum elements. Internally, the returned set will be backed by an EnumSet.

The iteration order of the returned set follows the enum's iteration order, not the order in which the elements appear in the given collection.

关于java - EnumSet 的不可变版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28413670/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com