Convert string to a short value

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 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.

public class Main {
  public static void main(String[] args) {

    System.out.println(Short.parseShort("10"));
    System.out.println(Short.parseShort("10",8));
    
    System.out.println(Short.valueOf("10"));
    System.out.println(Short.valueOf("10",8));
    

  }
}

The output:


10
8
10
8
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