JAVA:映射字符串键意味着什么?

JAVA:映射字符串键意味着什么?,java,hashmap,mapping,hashtable,Java,Hashmap,Mapping,Hashtable,我被分配了这个任务,老师要求我们去做 //Create a hash table where the initial storage //is 7 and string keys can be mapped to Q values 我的问题是将字符串映射到Q值意味着什么?如果这是一个简单的问题,我很抱歉,但我对这个问题很陌生 另外,我不确定它是否会改变答案,但在代码中,我们不能使用任何Java集合库,因此我必须从头开始编写此代码,因此第一点使用初始存储7创建HashMap,下一行

我被分配了这个任务,老师要求我们去做

    //Create a hash table where the initial storage
   //is 7 and string keys can be mapped to Q values
我的问题是将字符串映射到Q值意味着什么?如果这是一个简单的问题,我很抱歉,但我对这个问题很陌生


另外,我不确定它是否会改变答案,但在代码中,我们不能使用任何Java集合库,因此我必须从头开始编写此代码,因此第一点使用初始存储7创建HashMap,下一行创建初始容量为7的
HashMap
,它接受
String
类型键和
String
类型值

HashMap<String, String> map = new HashMap<String, String>(7);
根据需要,您需要使用
String
类型键和
Q
类型值创建
HashMap
,因此我认为
Q
必须是类或接口

HashMap<String, Q> map = new HashMap<String, Q>(7);
在上面的代码中,默认初始容量为7
hashmapcust hashmapcust=newhashmapcust()

但是您仍然需要为
put
delete
get
以及所需的方法编写自己的逻辑。我建议你检查一下这个

HashMap<String, Q> map = new HashMap<String, Q>(7);
class HashMapCustom<K, V> {

 private Entry<K,V>[] table;   //Array of Entry.
 private int capacity= 7;  //Initial capacity of HashMap

 static class Entry<K, V> {
     K key;
     V value;
     Entry<K,V> next;

     public Entry(K key, V value, Entry<K,V> next){
         this.key = key;
         this.value = value;
         this.next = next;
     }
 }

public HashMapCustom(){
   table = new Entry[capacity];
}