code: public static int[] add (int[] list, int value)
      {
          // make sure we've got a list to work with
          if (list == null) {
              return new int[] { value };
          }
  
          // check to see if the element is in the list
          int llength = list.length;
          for (int i = 0; i < llength; i++) {
              if (list[i] == value) {
                  return list;
              }
          }
  
          // expand the list and append our element
          int[] nlist = new int[llength+1];
          System.arraycopy(list, 0, nlist, 0, llength);
          nlist[llength] = value;
  
          return nlist;
      }
docs: Adds the specified value to the list iff it is not already in the
  list.
  
  @param list the list to which to add the value. Can be null.
  @param value the value to add.
  
  @return a reference to the list with value added (might not be the
  list you passed in due to expansion, or allocation).