Simple one this morning, but causing me issues and can’t seem to find any code out there. I have created a hex representation of a number, and wish to now save the last 4 characters of the hex string to then convert back to an integer.
The code that converts is shown below:
int in2 = new Integer(mycard.resourceid.toString());
String hex = Integer.toHexString(in2);
If someone could nudge me in the right direction I would be most appreciative.
int in3 = new Integer(hex.length());
int in4 = new Integer (in3 - 4);
String mystring = hex.subString(in4, in3);
If you just want a nudge, look for the
substringmethod of theStringclass.EDIT: Some sample code in response to OP followup: