Remove an element from the specified index. @webref stringlist:method @brief Remove an element from the specified index
(int index)
| 188 | * @brief Remove an element from the specified index |
| 189 | */ |
| 190 | public String remove(int index) { |
| 191 | if (index < 0 || index >= count) { |
| 192 | throw new ArrayIndexOutOfBoundsException(index); |
| 193 | } |
| 194 | String entry = data[index]; |
| 195 | // int[] outgoing = new int[count - 1]; |
| 196 | // System.arraycopy(data, 0, outgoing, 0, index); |
| 197 | // count--; |
| 198 | // System.arraycopy(data, index + 1, outgoing, 0, count - index); |
| 199 | // data = outgoing; |
| 200 | for (int i = index; i < count-1; i++) { |
| 201 | data[i] = data[i+1]; |
| 202 | } |
| 203 | count--; |
| 204 | return entry; |
| 205 | } |
| 206 | |
| 207 | |
| 208 | // Remove the first instance of a particular value and return its index. |