code: public void reverse(int start) {
      int end = size - 1;
      int num = end - start >> 1;
      for (int i = 0; i <= num; i++) {
        int j = start + i;
        int k = end - i;
        char c = buf[k];
        buf[k] = buf[j];
        buf[j] = c;
      }
    }
docs: Reverse all characters from start to end of buffer.