| java.lang.Object | |||||||||||||||||||||||||||||||||||||||||||
| | | |||||||||||||||||||||||||||||||||||||||||||
| | | - | - | java.lang.Number | ||||||||||||||||||||||||||||||||||||||||
| | | |||||||||||||||||||||||||||||||||||||||||||
| | | - | - | java.lang.Long | ||||||||||||||||||||||||||||||||||||||||
The Long class wraps a value of long in an object. Long class provides several methods for converting a long to a String and a String to a long.
Constants value from Long class
| Type | Field | Summary |
|---|---|---|
| static long | MAX_VALUE | Maximum value a long can have, 2^63-1. |
| static long | MIN_VALUE | Minimum value a long can have, -2^63. |
| static int | SIZE | The number of bits used to represent a long value in two's complement binary form. |
| static Class<Long> | TYPE | The Class instance representing the primitive type long. |
Constructors from Long
| Constructor | Summary |
|---|---|
| Long(long value) | Creates a Long object from long argument. |
| Long(String s) | Creates a Long object from the long value indicated by the String parameter. |
Convert long value to byte, double, float, int, long, short
| Return | Method | Summary |
|---|---|---|
| byte | byteValue() | Returns the value of this Long as a byte. |
| double | doubleValue() | Returns the value of this Long as a double. |
| float | floatValue() | Returns the value of this Long as a float. |
| int | intValue() | Returns the value of this Long as an int. |
| long | longValue() | Returns the value of this Long as a long value. |
| short | shortValue() | Returns the value of this Long as a short. |
Decode a string to create long value
| Return | Method | Summary |
|---|---|---|
| static Long | decode(String nm) | Decodes a String into a Long. |
Get the long value from a string
| Return | Method | Summary |
|---|---|---|
| static Long | getLong(String nm) | Determines the long value of the system property with the specified name. |
| static Long | getLong(String nm, long val) | Determines the long value of the system property with the specified name. |
| static Long | getLong(String nm, Long val) | Returns the long value of the system property with the specified name. |
Compare two long values
| Return | Method | Summary |
|---|---|---|
| int | compareTo(Long anotherLong) | Compares two Long objects numerically. |
| boolean | equals(Object obj) | Compares this object to the specified object. |
Parse long value from string
| Return | Method | Summary |
|---|---|---|
| static long | parseLong(String s) | Parses the string argument as a signed decimal long. |
| static long | parseLong(String s, int radix) | Parses the string as a signed long in the radix. |
| static Long | valueOf(long l) | Returns a Long instance representing the specified long value. |
| static Long | valueOf(String s) | Returns a Long object holding the value of the specified String. |
| static Long | valueOf(String s, int radix) | Returns a Long object holding the value extracted from the String with the radix. |
Convert long value to binary, hex and octal format strings
| Return | Method | Summary |
|---|---|---|
| static String | toBinaryString(long i) | Returns a string representation of the long argument as an unsigned integer in base 2. |
| static String | toHexString(long i) | Returns a string representation of the long argument as an unsigned integer in base 16. |
| static String | toOctalString(long i) | Returns a string representation of the long argument as an unsigned integer in base 8. |
Convert long value to string
| Return | Method | Summary |
|---|---|---|
| String | toString() | Returns a String object representing this Long's value. |
| static String | toString(long i) | Returns a String object representing the specified long. |
| static String | toString(long i, int radix) | Returns a string representation of the first argument in the radix. |
Get the sign of the long value
| Return | Method | Summary |
|---|---|---|
| static int | signum(long i) | Returns the signum function of the specified long value. |
Get the number of zero bits preceding and following
| Return | Method | Summary |
|---|---|---|
| static int | numberOfLeadingZeros(long i) | Returns the number of zero bits preceding the highest-order ("leftmost") one-bit in the two's complement binary representation. |
| static int | numberOfTrailingZeros(long i) | Returns the number of zero bits following the lowest-order ("rightmost") one-bit in the two's complement binary representation. |
Reverse and rotate a long value
| Return | Method | Summary |
|---|---|---|
| static long | reverse(long i) | Returns the value obtained by reversing the order of the bits in the two's complement binary representation. |
| static long | reverseBytes(long i) | Returns the value obtained by reversing the order of the bytes in the two's complement representation. |
| static long | rotateLeft(long i, int distance) | Returns the value obtained by rotating the two's complement binary representation left by the number of bits. |
| static long | rotateRight(long i, int distance) | Returns the value obtained by rotating the two's complement binary representation right by the number of bits. |
Bit oriented operation on long value
| Return | Method | Summary |
|---|---|---|
| static int | bitCount(long i) | Returns the number of one-bits in the two's complement binary representation of the specified long value. |
| static long | highestOneBit(long i) | Returns a long value with at most a single one-bit, in the position of the highest-order ("leftmost") one-bit. |
| static long | lowestOneBit(long i) | Returns a long value with at most a single one-bit, in the position of the lowest-order ("rightmost") one-bit. |
java2s.com | | Contact Us | Privacy Policy |
| Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
| All other trademarks are property of their respective owners. |