Question:
How to convert ASCII code to char in Java?
Answer:
Simply casting int to char
Code:
public class ConvertASCIItoChar { public static void main(String[] args) { for(int i=32;i<=126;i++){ char c = (char)i; System.out.print(c); } System.out.println(); } }
Output:
$ java ConvertASCIItoChar !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~