private int forward(int obj) {
    // There are three cases that you will need to handle here.
    // 1) If obj is not a pointer (i.e., if it is greater than
    //    or equal to zero), then you should just return obj
    //    directly.
    // 2) If obj is a pointer, but the length field of the object
    //    that it points to is negative, then (a) we can conclude
    //    that the object has already been forwarded; and (b) we
    //    can just return the (negative) length value, which is a
    //    pointer to the object's new location in toSpace.
    // 3) If obj is a pointer and the length field is non negative,
    //    then it points to an object that needs to be forwarded to
    //    toSpace.  This requires us to copy the length word and
    //    the associated fields from the heap into the toSpace.
    //    After that, we overwrite the length field with a pointer
    //    to the location of the object in toSpace (because it is
    //    a pointer, this will be a negative number).
    // The description here is longer than my code!


      if (obj >= 0) return obj;
      int addy = size+obj;
      int retval = hp;
      if (heap[addy] < 0)  return heap[addy];

      if (heap[addy] >= 0){
          for (int i = 0; i <= heap[addy]; i++){
              toSpace[hp++] = heap[addy+i];
          }
          heap[addy] = retval-size;
      }
      return retval;
  }