Byte class Methods in Java

java.lang.Byte

The Byte class wraps a value of primitive type byte in an object. An object of type Byte contains a single field whose type is a byte. In addition, this class provides several methods for converting a byte to a String and a String to a byte, as well as other constants and methods useful when dealing with a byte.

Some methods of Byte class

Byte.BYTESThe number of bytes used to represent a byte value in twos-complement binary form.

Byte.compare()It compares two-byte values numerically.

Byte.compareUnsigned() It compares two-byte values numerically treating the values as unsigned.

Byte.decode() It decodes a String into a Byte. Accepts decimal, hexadecimal, and octal number.

Byte.hashCode(): It returns a hash code for a byte value.

Byte.MAX_VALUEA constant holding the maximum value a byte can have, 2^7-1 (127).

Byte.MIN_VALUEA constant holding the minimum value a byte can have, -2^7 or (-128).

Byte.parseByte()It parses the string argument as a signed decimal byte. The characters in the string must all be decimal digits, except that the first character may be an ASCII minus sign '-' ('\u005Cu002D') to indicate a negative value or an ASCII plus sign '+'('\u005Cu002B') to indicate a positive value.

Byte.parseByte(String s, int radix)It parses the string argument as a signed byte in the radix specified by the second argument.

Byte.SIZEThe number of bits used to represent a byte value in twos-complement binary form.

Byte.toString()It returns a new String object representing the specified byte. The radix is assumed to be 10.

Byte.toUnsignedInt()It converts the argument to an int by an unsigned conversion. In an unsigned conversion to an int, the high-order 24 bits of the int are zero and the low-order 8 bits are equal to the bits of the byte argument.

Byte.toUnsignedLong()It converts the argument to a long by an unsigned conversion. In an unsigned conversion to a long, the high-order 56 bits of the long are zero and the low-order 8 bits are equal to the bits of the byte argument.

Byte.valueOf(byte b)It returns a Byte instance representing the specified byte value.

Byte.valueOf(String s, int radix)It returns a Byte object holding the value extracted from the specified String when parsed with the radix given by the second argument. The first argument is interpreted as representing a signed byte in the radix specified by the second argument.

Byte.valueOf(String s)It returns a Byte object holding the value given by the specified String.


No comments:

Post a Comment