There are no unsigned types in Java, so your array should contain the usual char values. However, numeric literals are int by default, so you may need to drop your values ββto char , for example: (char)0x41 . The same applies to byte values ββ(use one or another option depending on whether your numbers are ASCII or Unicode BMP values). You can also use unicode escape code, for example String str = "\u0041\u0042"; . To get the byte representation of an ASCII string (or otherwise encoded) (the opposite operation), use the syntax, for example: String charArray = "abcd".getBytes("UTF-8"); .
Also note the difference between bytes and characters. A character is well defined by the Unicode standard and always has the same meaning. The byte value depends on the character encoding used, so you cannot just make a string of bytes. If you use the String(byte[]) constructor String(byte[]) , you use non-standard platform coding - this can be dangerous in some situations. String(char[]) , on the other hand, is safe (but if you generate char values ββby casting hexadecimal numbers to char s, you de facto manually convert from ASCII).
source share