/*---------------------------------------------------------------------------- Important: System.out.println() is overloaded !!!! System.out.println(char x) will interpret input x using ASCII code System.out.println(int x) will interpret input x using 2s compl code ----------------------------------------------------------------------------*/ public class ascii { public static void main(String[] args) { char c; c = 'A'; System.out.println("c = " + c); // Use ASCII code c = (char) (c + 1); // type of c+1 is int, need casting System.out.println("c = " + c); // Use ASCII code c = 65; System.out.println("c = " + c); // Use ASCII code c = (char) (c + 1); // type of c+1 is int, need casting System.out.println("c = " + c); // Use ASCII code /* int i; i = c; // i contains the same binary value as c ! System.out.println("i = " + i); // Use 2s compl code (because i is int) */ } }