I am a new programmer of java ,I want to convert a string into hex .Suppose if I have a value "A" then the program must convert it into "41",if I have "B" then it must be converted into "42".
Kindly write the complete program
You do it Looks like you want the ASCII character value as a hex string.
Use the Integer.valueOf method to convert the character value of the String to it's decimal ASCII value. Then use the Integer.toString method with a radix argument to convert that decimal value to a string representation of its hex value (that's the long way round ).
All truths are easy to understand once they are discovered; the point is to discover them...
Last edited by dlorde; August 11th, 2010 at 06:29 PM.
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
Did you try this:
Extract a char from the String (see String methods) and use the Integer.toHexString() method
A char will convert to an int for the method call above.
Loop over the length of the String.