Short Class Methods in Java

java.lang.Short

The Short class wraps a value of primitive type short in an object. An object of type Short contains a single field whose type is short. In addition, this class provides several methods for converting a short to a String and a String to a short, as well as other constants and methods useful when dealing with a short.


Some of the methods of Short class


byteValue()This method returns the value of this Short as a byte after a narrowing primitive conversion.


Short.compare()This method compares two short values numerically.


compareTo() This method compares two Short objects numerically.


Short.compareUnsigned()This method compares two short values numerically treating the values as unsigned.


Short.decode()This method decodes a String into a Short. Accepts decimal, hexadecimal, and octal numbers.


doubleValue(): This method returns the value of this Short as a double after a widening primitive conversion.


equals()This method compares this object to the specified object. The result is true if and only if the argument is not null and is a Short object that contains the same short value as this object.


floatValue()This method returns the value of this Short as the float after a widening primitive conversion.


hashCode()This method returns a hash code for this Short; equal to the result of invoking intValue().


intValue()This method returns the value of this Short as an int after a widening primitive conversion.


longValue()This method returns the value of this Short as a long after a widening primitive conversion.


Short.parseShort(): This method parses the string argument as a signed decimal short. 


Short.reverseBytes()This method returns the value obtained by reversing the order of the bytes in the two's complement representation of the specified short value.


shortValue()This method returns the value of this Short as a short.


Constants of Short class: This contains constant values, Short.BYTES,  Short.MAX_VALUE, Short.MIN_VALUE, Short.SIZE.


toString()The value is converted to signed decimal representation and returned as a string.


Short.toUnsignedInt()This method converts the argument to an int by an unsigned conversion. 


Short.toUnsignedLong()This method converts the argument to a long by an unsigned conversion. 


Short.valueOf()This method returns a Short instance representing the specified short value.


No comments:

Post a Comment