How to convert ASCII code (0-255) to its corresponding character?

How can I convert, in Java, the ASCII code (which is an integer from [0, 255] range) to its corresponding ASCII character?

For example:

65  -> "A"
102 -> "f"

Character.toString ((char) i);


System.out.println((char)65); would print "A"


String.valueOf(Character.toChars(int))

Assuming the integer is, as you say, between 0 and 255, you'll get an array with a single character back from Character.toChars, which will become a single-character string when passed to String.valueOf.

Using Character.toChars is preferable to methods involving a cast from int to char (i.e. (char) i) for a number of reasons, including that Character.toChars will throw an IllegalArgumentException if you fail to properly validate the integer while the cast will swallow the error (per the narrowing primitive conversions specification), potentially giving an output other than what you intended.