Java Short Number Create toShort(Object obj)

Here you can find the source of toShort(Object obj)

Description

Get the short value of this object, only if the object is an instance of Number

License

Open Source License

Parameter

Parameter Description
obj the object to be converted

Return

the short value of the object, or 0 if it is not a number.

Declaration

public static short toShort(Object obj) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from  w  w  w. j  ava  2 s .co  m*/
     * Get the short value of this object, only if the object is an instance of Number
     *
     * @param obj the object to be converted
     * @return the short value of the object, or 0 if it is not a number.
     */
    public static short toShort(Object obj) {
        return (obj instanceof Number) ? ((Number) obj).shortValue() : 0;
    }
}

Related

  1. toShort(Number value)
  2. toShort(Object o)
  3. toShort(Object ob, Short defaultShort)
  4. toShort(Object obj)
  5. toShort(Object obj)
  6. toShort(Object obj)
  7. toShort(Object prmIntObject)
  8. toShort(Object value)
  9. toShort(Object value)