What is the toHexString() method of the Integer class?
Are you preparing for IT certification? With practice questions, study notes, interactive quizzes, tips and technical articles, uCertify PrepKits ensure that you get a solid grasp of core technical concepts to ace your certification exam in first attempt.
What is the toHexString() method of the Integer class?
Rating:
The toHexString() method converts an integer value into a hexadecimal string. The Integer class defines this method with the following signature:
The given signature of the method suggests that it takes an int argument and returns a String object. The String object returned by the method is a string that represents an unsigned integer in base 16.
The toHexString() method works as follows:
- If the argument to the method is a positive value, then the method converts this value to a string of ASCII digits in hexadecimal (base 16) with no extra leading zeros.
- If the argument to the method is a negative value, the method first adds the value 232 to the value. The value so obtained is then converted to a string of ASCII digits in hexadecimal (i.e., base 16) format with no extra leading zeros.
Rating:
Was this information helpful?
Other articles
- What is the bitwise OR operator?
- Java Control Statements
- What is the random() method?
- What is the FileOutputStream class?
- What are variable length arguments?