java.lang.Short Class & Methods


The java.lang.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. This class provides several utility 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.

Short class implements Comparable Interface that’s help while sorting list of Objects on natural order.

See Also:

Constants

  • static short MAX_VALUE :A constant holding the maximum value a short can have, 215-1.
  • static short MIN_VALUE :A constant holding the minimum value a short can have, -215.
  • static int SIZE :The number of bits used to represent a short value in two’s complement binary form.
  • static Class TYPE :The Class instance representing the primitive type short.

Constructors

  • Short(short value) :Constructs a newly allocated Short object that represents the specified short value.
  • Short(String s) :Constructs a newly allocated Short object that represents the short value indicated by the String parameter.

Methods

  • byte byteValue() :Returns the value of this Short as a byte.
  • static int compare(short x, short y) :Compares two short values numerically.
  • int compareTo(Short anotherShort) :Compares two Short objects numerically.
  • static Short decode(String nm) :Decodes a String into a Short.
  • double doubleValue() :Returns the value of this Short as a double.
  • boolean equals(Object obj) :Compares this object to the specified object.
  • float floatValue() :Returns the value of this Short as a float.
  • int hashCode() :Returns a hash code for this Short; equal to the result of invoking intValue().
  • int intValue() :Returns the value of this Short as an int.
  • long longValue() :Returns the value of this Short as a long.
  • static short parseShort(String s) :Parses the string argument as a signed decimal short.
  • static short parseShort(String s, int radix) :Parses the string argument as a signed short in the radix specified by the second argument.
  • static short reverseBytes(short i) :Returns the value obtained by reversing the order of the bytes in the two’s complement representation of the specified short value.
  • short shortValue() :Returns the value of this Short as a short.
  • String toString() :Returns a String object representing this Short’s value.
  • String toString(short s) :Returns a new String object representing the specified short.
  • static Short valueOf(short s) :Returns a Short instance representing the specified short value.
  • static Short valueOf(String s) :Returns a Short object holding the value given by the specified String.
  • static Short valueOf(String s, int radix) :Returns a Short object holding the value extracted from the specified String when parsed with the radix given by the second argument.

Exceptions

References

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s