📜  Java.lang.Short类

📅  最后修改于: 2020-11-15 03:05:26             🧑  作者: Mango


介绍

java.lang.Short类在对象中包装一个基本类型为short的值。类型为Short的对象包含一个类型为short的字段。

类声明

以下是java.lang.Short类的声明-

public final class Short
   extends Number
      implements Comparable

领域

以下是java.lang.Short类的字段-

  • 静态short MAX_VALUE-这是一个常量,它包含一个short可以具有的最大值2 15 -1。

  • 静态short MIN_VALUE-这是一个常量,它包含一个short可以具有的最小值-2 15

  • static int SIZE-这是用来表示二进制补码二进制形式的短值的位数。

  • 静态Class TYPE-这是Class实例,表示原始类型short。

类的构造函数

Sr.No. Constructor & Description
1

Short(short value)

This constructs a newly allocated Short object that represents the specified short value.

2

Short(String s)

This constructs a newly allocated Short object that represents the short value indicated by the String parameter.

类方法

Sr.No. Method & Description
1 byte byteValue()

This method returns the value of this Short as a byte.

2 int compareTo(Short anotherShort)

This method compares two Short objects numerically.

3 static Short decode(String nm)

This method decodes a String into a Short.

4 double doubleValue()

This method returns the value of this Short as a double.

5 boolean equals(Object obj)

This method compares this object to the specified object.

6 float floatValue()

This method returns the value of this Short as a float.

7 int hashCode()

This method returns a hash code for this Short.

8 int intValue()

This method returns the value of this Short as an int.

9 long longValue()

This method returns the value of this Short as a long.

10 static short parseShort(String s)

This method parses the string argument as a signed decimal short.

11 static short parseShort(String s, int radix)

This method parses the string argument as a signed short in the radix specified by the second argument.

12 static short reverseBytes(short i)

This method returns the value obtained by reversing the order of the bytes in the two’s complement representation of the specified short value.

13 short shortValue()

This method returns the value of this Short as a short.

14 String toString()

This method returns a String object representing this Short’s value.

15 static String toString(short s)

This method returns a new String object representing the specified short.

16 static Short valueOf(short s)

This method returns a Short instance representing the specified short value.

17 static Short valueOf(String s)

This method returns a Short instance representing the specified short value.

18 static Short valueOf(String s, int radix)

This method returns a Short object holding the value extracted from the specified String when parsed with the radix given by the second argument.

方法继承

此类从以下类继承方法-

  • java.lang.Object