Hi,
Back to basics. If I define a string say
String str = "0x23FF";
actually how many bytes it takes in the memory ? It says that each char in java is 2 bytes and hence 12 bytes.
but a code like
byte[] utf8 = null;
int byteCount = 0;
try {
utf8 = str.getBytes("UTF-8");
byteCount = utf8.length;
} catch (Exception ex) {
ex.printStackTrace();
}
System.out.printf("UTF-8 Byte Count: %d\n", byteCount);
prints only 6.
I was thinking which would be the efficient way to store a string of this sort (hex numbers) as Long or String ?
Regards,
HiAll