Conversion between hexadecimal in java and java hexadecimal conversion
// Convert decimal to other hexadecimal
Integer. toHexString (10); // converts 10 to hexadecimal format, and returns the string type.
Integer. toOctalString (10); // convert 10 to octal and return the string type.
Integer. toBinaryString (10); // convert 10 to binary and return the string type.
// Convert other hexadecimal values to decimal values
// Convert hexadecimal to decimal, for example, 0 xFFFF
Integer. valueOf ("FFFF", 16). toString (); // the valueOf () method returns the Integer type, and the toString () method is called to return the string.
Integer. parseInt ("FFFF", 16); // returns the basic int data type.
Integer. toString (0 xFFFF); // This method can be used to directly input the basic data type that represents a hexadecimal number. The method returns a string.
// Convert octal to decimal, for example, 017
Integer. valueOf ("17", 8). toString (); // the valueOf () method returns the Integer type. Call toString () to return the string.
Integer. parseInt ("17", 8); // returns the basic int data type.
Integer. toString (017); // This method can be used to directly input the basic data type representing the octal number. The method returns a string.
// Convert binary to decimal, for example: 0101
Integer. valueOf ("0101", 2). toString (); // the valueOf () method returns the Integer type. Call toString () to return the string.
Integer. parseInt ("0101", 2); // returns the basic int data type.
// For the conversion between binary, octal, and hexadecimal, You can first convert it to decimal, and convert it in the corresponding method of convert it into multi-hexadecimal
// For example, convert hexadecimal 0xFF to binary
Integer. toBinaryString (Integer. valueOf ("FF", 16 ));
// Or
Integer. toBinaryString (Integer. parseInt ("FF", 16 ));
// For the input string that represents the hexadecimal format, you must first intercept the number substring and convert it to decimal using the valueOf () or parseInt () method.
// For example, enter 0xFF
String s = "0xFF ";
Integer. valueOf (s. subString (2, s. length (), 16 );
// For the valueOf method, it can be used for packing basic data types and conversion from multi-hexadecimal to decimal.