Example usage for java.lang Short shortValue

List of usage examples for java.lang Short shortValue

Introduction

In this page you can find the example usage for java.lang Short shortValue.

Prototype

@HotSpotIntrinsicCandidate
public short shortValue() 

Source Link

Document

Returns the value of this Short as a short .

Usage

From source file:MainClass.java

public static void main(String[] args) {
    short s = -1800;
    Short s2 = new Short(s);
    System.out.println(s2.shortValue());
}

From source file:Main.java

public static void main(String[] args) {
    Short shortObject = new Short("10");
    short s = shortObject.shortValue();
    System.out.println("short:" + s);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Boolean refBoolean = new Boolean(true);
    boolean bool = refBoolean.booleanValue();

    Byte refByte = new Byte((byte) 123);
    byte b = refByte.byteValue();

    Character refChar = new Character('x');
    char c = refChar.charValue();

    Short refShort = new Short((short) 123);
    short s = refShort.shortValue();

    Integer refInt = new Integer(123);
    int i = refInt.intValue();

    Long refLong = new Long(123L);
    long l = refLong.longValue();

    Float refFloat = new Float(12.3F);
    float f = refFloat.floatValue();

    Double refDouble = new Double(12.3D);
    double d = refDouble.doubleValue();
}

From source file:Main.java

public static void main(String[] args) {
    Short sObj = new Short("10");

    byte b = sObj.byteValue();
    System.out.println(b);// w  w  w. j a  v a  2 s.com

    short s = sObj.shortValue();
    System.out.println(s);

    int i = sObj.intValue();
    System.out.println(i);

    float f = sObj.floatValue();
    System.out.println(f);

    double d = sObj.doubleValue();
    System.out.println(d);

    long l = sObj.longValue();
    System.out.println(l);
}

From source file:Main.java

/**
 * unbox Short/*from w w w  .  j  a v  a2s.c  o  m*/
 */
public static short unboxed(Short v) {
    return v == null ? 0 : v.shortValue();
}

From source file:com.hbc.api.trade.bdata.common.util.ParameterValidator.java

/**
 * @param paramValue ??/*from  w  w w .  j a v  a 2 s.  c  o m*/
 * @param paramNameTip ????
 */
public static void validateParamNumberGreaterThan0(Short paramValue, String paramNameTip) {
    if (paramValue == null || paramValue.shortValue() < 0) {
        throw new ParamValidateException(CommonReturnCodeEnum.PARAM_ERROR_WITHARG, paramNameTip);
    }
}

From source file:Main.java

/**
 * Converts to primitive array.//from  w w w  .ja va  2  s .  com
 */
public static short[] values(Short[] array) {
    short[] dest = new short[array.length];
    for (int i = 0; i < array.length; i++) {
        Short v = array[i];
        if (v != null) {
            dest[i] = v.shortValue();
        }
    }
    return dest;
}

From source file:org.onosproject.drivers.microsemi.yang.utils.CeVlanMapUtils.java

/**
 * Remove a vlan id from an existing string representation.
 * @param existingMap An array of vlan ids
 * @param vlanRemove The vlan ID to remove
 * @return A string representation delimited by commas and colons
 *///  ww w. j  a v  a2s.co m
public static String removeFromCeVlanMap(String existingMap, Short vlanRemove) {
    Short[] vlanArray = getVlanSet(existingMap);
    TreeSet<Short> vlanSet = new TreeSet<>();
    for (Short vlan : vlanArray) {
        if (vlan.shortValue() != vlanRemove.shortValue()) {
            vlanSet.add(vlan);
        }
    }

    return vlanListAsString(vlanSet.toArray(new Short[vlanSet.size()]));
}

From source file:com.meetup.memcached.NativeHandler.java

protected static byte[] encode(Short value) throws Exception {
    return encode((int) value.shortValue());
}

From source file:Main.java

/**
 * <p>Converts an array of object Short to primitives handling {@code null}.</p>
 *
 * <p>This method returns {@code null} for a {@code null} input array.</p>
 *
 * @param array  a {@code Short} array, may be {@code null}
 * @param valueForNull  the value to insert if {@code null} found
 * @return a {@code byte} array, {@code null} if null array input
 *///from   ww  w.  j  a v a2s  . c o m
public static short[] toPrimitive(Short[] array, short valueForNull) {
    if (array == null) {
        return null;
    } else if (array.length == 0) {
        return EMPTY_SHORT_ARRAY;
    }
    final short[] result = new short[array.length];
    for (int i = 0; i < array.length; i++) {
        Short b = array[i];
        result[i] = (b == null ? valueForNull : b.shortValue());
    }
    return result;
}