I wish to append a byte i.e. 16 = 0x10 to a String, using escape sequence to do it in single line of code:
String appendedString = new String('\16'+"String");
This results in a hex representation of appendedString = 0x0E,0x74,0x72,0x69,0x6E,0x67
using a \2 like this:
String appendedString = new String('\2'+"String");
works fine resulting in a hex representation of appendedString = 0x02,0x74,0x72,0x69,0x6E,0x67
using a \10:
String appendedString = new String('\10'+"String");
results in a hex representation of appendedString = 0x08,0x74,0x72,0x69,0x6E,0x67
Someone may kindly explain this and suggest a solution. Thanks.