有kotlin设置代码,如下所示:val CITIES_WITH_LOGIN_ENABLED = setOf<CustomCity>(CustomCity.MUNICH, CustomCity.BERLIN, CustomCity.SAIGON, CustomCity.TESTMUNICH, CustomCity.TBILISI)我想将该代码转换为Java,它的等效Java代码是什么?
3 回答
![?](http://img1.sycdn.imooc.com/545868190001d52602200220-100-100.jpg)
当年话下
TA贡献1890条经验 获得超9个赞
Set
如果研究setOf()
其不可变集的定义,该不可变集仅包含指定的对象,并且该集是可序列化的,则其等效于Java 。
您可以检查Menu > Tools > Kotlin > Show Kotlin Bytecode > Decompile
。
您可以使用HashSet
其序列化(注意类型)
Set<CustomCity> set = new HashSet<>(Arrays.asList(CustomCity.MUNICH,CustomCity.TBILISI));
添加回答
举报
0/150
提交
取消