202 |
} |
} |
203 |
|
|
204 |
/** |
/** |
205 |
|
* Returns a <code>Short</code> object wrapping the value. |
206 |
|
* In contrast to the <code>Short</code> constructor, this method |
207 |
|
* will cache some values. It is used by boxing conversion. |
208 |
|
* |
209 |
|
* @param val the value to wrap |
210 |
|
* @return the <code>Short</code> |
211 |
|
* |
212 |
|
* @since 1.5 |
213 |
|
*/ |
214 |
|
public static Short valueOf(short val) |
215 |
|
{ |
216 |
|
if (val < MIN_CACHE || val > MAX_CACHE) |
217 |
|
return new Short(val); |
218 |
|
synchronized (shortCache) |
219 |
|
{ |
220 |
|
if (shortCache[val - MIN_CACHE] == null) |
221 |
|
shortCache[val - MIN_CACHE] = new Short(val); |
222 |
|
return shortCache[val - MIN_CACHE]; |
223 |
|
} |
224 |
|
} |
225 |
|
|
226 |
|
/** |
227 |
* Convert the specified <code>String</code> into a <code>Short</code>. |
* Convert the specified <code>String</code> into a <code>Short</code>. |
228 |
* The <code>String</code> may represent decimal, hexadecimal, or |
* The <code>String</code> may represent decimal, hexadecimal, or |
229 |
* octal numbers. |
* octal numbers. |