How can I generate a hexadecimal code from another sequence of numbers?

2

I'm doing a code generator app, I need to generate a hexadecimal code from the code entered by the user and show this generated hexadecimal code. Could someone explain to me how I can get to this? I'm a beginner in this area.

    
asked by anonymous 11.02.2015 / 19:57

1 answer

1

If you have a string with any number, for example:

String str = "43956";

You must first convert this to an integer, like this:

int num = Integer.valueOf(str).intValue();

You can then convert this number to a string of hexadecimal digits, like this:

String hex = Integer.toHexString(num);

Now it's a matter of organizing your UI to display this value.

Documentation:

Integer.valueOf(String s) Integer.intValue() Integer.toHexString(int i)

    
11.02.2015 / 23:24