这里举例如何将数组存入HashMap中
//实例化
HashMap Map <Integer,Integer> map = new HashMap<>();
// 定义一个int型数组
int []arr = new int[]{1,2,3};
// for循环
for(int cur = 0,temp;cur<arr.length;cur++)
{
temp = arr[cur];
map.put(temp,cur);
}
// 判断HashMap中是否有当前元素,返回boolean类型 ,value为待判断元素
map.containsKey(value);
// 获取指定元素下标
map.get(value);
// 清空HashMap
map.clear();