简体   繁体   中英

String to Hex Short java

I have a variable define as

short s1 = 0x3039;

to do some operation, converting it to string

String ss = Integer.toHexString(s1 & 0xffff);

which give result as string "3039". After some string operation it is converted to string "3130". Now i want it back as

short s2 = 0x3130;

How can this be achieved ?

您可以将Short.parseShort用作基数16

Short.parseShort(yourHexString, 16)                             
short s2 = Short.valueOf(ss2).shortValue();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM