Short class


  public final class Short extends Number implements Comparable<Short>
  

The Short class wraps the short value in an object. Short class provides several methods for converting a short to a String and a String to a short.

Constants defined by Short class

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.

Constructors from Short class

Short(short value)
Creates a Short object that represents the specified short value.
Short(String s)
Creates a Short object that represents the short value indicated by the String parameter.

Methods from Shorts class for converting short value to byte, double, float, int, long and short

byte byteValue()
Returns the value of this Short as a byte.
double doubleValue()
Returns the value of this Short as a double.
float floatValue()
Returns the value of this Short as a float.
int intValue()
Returns the value of this Short as an int.
long longValue()
Returns the value of this Short as a long.
short shortValue()
Returns the value of this Short as a short.

Converting Short to string

String toString()
Returns a String object representing this Short's value.
static String toString(short s)
Returns a new String object representing the specified short.

Convert string to short value

static Short decode(String nm)
Decodes a String into a Short.
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.
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.

Compare two Short objects

int compareTo(Short anotherShort)
Compares two Short objects numerically.
boolean equals(Object obj)
Compares this object to the specified object.
Home 
  Java Book 
    Essential Classes  

Short:
  1. Short class
  2. Find out the min value, max value and size of Short types
  3. Create Short object with its constructor
  4. Convert Short to byte, double, float, int, long and short
  5. Decode a string to short value
  6. Convert string to a short value
  7. Reverse the bytes in a short
  8. Convert short value to string
  9. Compare two short values