我需要创建一种书籍索引方法,该方法可以将多个值与一个键配对
例如 key - “贝克,肯特” 值 - 27 23 76
这可能吗?
导入ou.*;是开放大学图书馆,不应该影响任何事情。
import java.util.*;
import ou.*;
public class BookIndex
{
public Map<String, Integer> index()
{
Map<String, Integer> actual = new HashMap<>();
return actual;
}
谢谢
最佳答案
在Map<String, Integer>
中使用整数数组而不是整数怎么样? .
HashMap<String, Integer[]> anewMap = new HashMap<String, Integer[]>();
anewMap.put("Beck,Kent",new Integer[] { 27, 23, 76});
关于java - 我需要在 Map 中保存多个 int 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16377404/