title: dictionary using array java
body: <p>My goal is to implement a dictionary using an array and I have got some problems with it.The methods put and get I don't think are good enough to work but I don't know what to modify.Here is the Dictionary class:</p>
  
  <pre><code>public class Dictionary implements IDictionary{
  public class ObjectDictionary{
      //public boolean isFull=false;
      public Object key;
      public Object value;
  
  }
  private ObjectDictionary[] elems; 
  private int nrElem;
  public Dictionary(){
      nrElem=0;
      elems=new ObjectDictionary[20];
  }
  public void resize(){
      ObjectDictionary[] ob = new ObjectDictionary[2*elems.length];
      for(int i=0;i&lt;elems.length;i++)
          ob[i]=elems[i];
      elems=ob;
  }
  public int size(){
       return nrElem;
   }
  public boolean isEmpty(){
      return nrElem==0;
  }
  public void put(Object k,Object v){
      for (int i=0; i&lt;elems.length;i++){  
          if (elems.length == nrElem){
              resize();
          elems[i].key=k;
          elems[i].value=v;
          //elems[i].isFull=true;
  
          }
      }
  }
  
  public Object get(Object k){
      for(int i=0; i&lt;elems.length;i++)
          if(elems[i].key.equals(k)){
              return elems[i].value;     
          }
      return null;
  }
  }
  </code></pre>
  
  <p>And this is the main method :</p>
  
  <pre><code>public class Start {
  public static void main(String[] args){
  IDictionary d = new Dictionary();
      d.put("a",1);
      d.put("b", 2);
      for(int i=0;i&lt;d.size();i++){
      System.out.println(d.get("a"));
  }
  }
  }
  </code></pre>
  
  <p>When I compile it only says terminated and I don't know how to fix it.Can anyone help me with an advice? Thank you very much.</p>