Intel

Developer Zone

Long

java.lang

Class Long

    • Field Summary

      Fields
      Modifier and Type Field and Description
      static long MAX_VALUE
      Constant for the maximum long value, 263-1.
      static long MIN_VALUE
      Constant for the minimum long value, -263.
    • Constructor Summary

      Constructors
      Constructor and Description
      Long(long value)
      Constructs a new Long with the specified primitive long value.
    • Method Summary

      Methods
      Modifier and Type Method and Description
      boolean equals(Object o)
      Compares this instance with the specified object and indicates if they are equal.
      int hashCode()
      Returns an integer hash code for this long.
      long longValue()
      Gets the primitive value of this long.
      static long parseLong(String string)
      Parses the specified string as a signed decimal long value.
      static long parseLong(String string, int radix)
      Parses the specified string as a signed long value using the specified radix.
      String toString()
      Converts this long into its decimal string representation.
      static String toString(long l)
      Converts the specified long value into its decimal string representation.
      static String toString(long l, int radix)
      Converts the specified long value into a string representation based on the specified radix.
      static Long valueOf(long lng)
      Returns a Long instance for the specified long value.
    • Field Detail

      • MAX_VALUE

        public static final long MAX_VALUE
        Constant for the maximum long value, 263-1.
        See Also:
        Constant Field Values
      • MIN_VALUE

        public static final long MIN_VALUE
        Constant for the minimum long value, -263.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Long

        public Long(long value)
        Constructs a new Long with the specified primitive long value.
        Parameters:
        value - the primitive long value to store in the new instance.
    • Method Detail

      • equals

        public boolean equals(Object o)
        Compares this instance with the specified object and indicates if they are equal. In order to be equal, o must be an instance of Long and have the same long value as this object.
        Overrides:
        equals in class Object
        Parameters:
        o - the object to compare this long with.
        Returns:
        true if the specified object is equal to this Long; false otherwise.
        See Also:
        Object.hashCode()
      • longValue

        public long longValue()
        Gets the primitive value of this long.
        Returns:
        this object's primitive value.
      • toString

        public String toString()
        Converts this long into its decimal string representation. The returned string is a concatenation of a minus sign if the number is negative and characters from '0' to '9'.
        Overrides:
        toString in class Object
        Returns:
        the decimal string representation of value.
      • toString

        public static String toString(long l)
        Converts the specified long value into its decimal string representation. The returned string is a concatenation of a minus sign if the number is negative and characters from '0' to '9'.
        Parameters:
        l - the long to convert.
        Returns:
        the decimal string representation of l.
      • toString

        public static String toString(long l,
                      int radix)
        Converts the specified long value into a string representation based on the specified radix. The returned string is a concatenation of a minus sign if the number is negative and characters from '0' to '9' and 'a' to 'z', depending on the radix. If radix is not in the interval defined by Character.MIN_RADIX and Character.MAX_RADIX then 10 is used as the base for the conversion.
        Parameters:
        l - the long to convert.
        radix - the base to use for the conversion.
        Returns:
        the string representation of l.
      • parseLong

        public static long parseLong(String string)
                              throws NumberFormatException
        Parses the specified string as a signed decimal long value. The ASCII character - ('-') is recognized as the minus sign.
        Parameters:
        string - the string representation of a long value.
        Returns:
        the primitive long value represented by string.
        Throws:
        NumberFormatException - if string is null, has a length of zero or can not be parsed as a long value.
      • parseLong

        public static long parseLong(String string,
                     int radix)
                              throws NumberFormatException
        Parses the specified string as a signed long value using the specified radix. The ASCII character - ('-') is recognized as the minus sign.
        Parameters:
        string - the string representation of a long value.
        radix - the radix to use when parsing.
        Returns:
        the primitive long value represented by string using radix.
        Throws:
        NumberFormatException - if string is null or has a length of zero, radix < Character.MIN_RADIX, radix > Character.MAX_RADIX, or if string can not be parsed as a long value.
      • valueOf

        public static Long valueOf(long lng)
        Returns a Long instance for the specified long value.

        If it is not necessary to get a new Long instance, it is recommended to use this method instead of the constructor, since it maintains a cache of instances which may result in better performance.

        Parameters:
        lng - the long value to store in the instance.
        Returns:
        a Long instance containing lng.
        Since:
        1.5