But this is implicit typecast and it can happen from short to int. In case of explicit this (short)5 can be done rifht? and more over valueOf()takes a string as argument.
:roll: thanks anyway for your help.
Joined: Aug 03, 2002
Please take the trouble to check the Java 5.0 API for Short.
public static Short valueOf(short s)
Returns a Short instance representing the specified short value. If a new Short instance is not required, this method should generally be used in preference to the constructor Short(short), as this method is likely to yield significantly better space and time performance by caching frequently requested values.
Parameters: s - a short value. Returns: a Short instance representing s. Since: 1.5
Short.valueOf takes a short as well as a String. If you looked at the byte code generated by the compiler (as I did before answering your question) you will see that what I have written is correct. [ October 02, 2006: Message edited by: Barry Gaunt ]
Shivaprasad P Kanaganahallimath
Joined: Sep 25, 2006
Waw!! thank you so much. I didn't know that it can take short as argument.