What is the toHexString() method of the Integer class?

September 22nd, 2007 by uCertify Leave a reply »

The toHexString() method converts an integer value into a hexadecimal string. The Integer class defines this method with the following signature:

public static String toHexString(int i)

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:

  1. 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.
  2. 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.
  • Share/Bookmark
Advertisement

Leave a Reply

uCertify.com | Our Company | Articles | Contact Us | News and Press Release | uCertify India | Entries (RSS)
MCSE: MCSA, MCTS, MCITP    JAVA Certification: SCJP, SCWCD    Cisco Certification: CCNA, CCENT    A+, Network+, Security+ Project+
Oracle Certification: OCP 11g, OCP 10g, OCA 11g, OCA 10g    CIW foundation    EC-212-32,    CISSP    Photoshop ACE CS4    Adobe Flash ACE, PMP, CAPM
© 2008 uCertify.com. All rights reserved. All trademarks are the property of their respective owners.