我想知道是否可以更改 java 数组用作索引的值,而不是
Fruit[0] = orange
你可以有
Fruit[orange] = orange
?
最佳答案
这类似于 associative array Perl 等语言中的表示法。在 Java 中,它们由 Maps
表示:
Map<String, String> fruitMap = new HashMap<>();
fruitMap.put("orange", "orange");
关于java - 更改数组的索引值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16006922/