Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. public class test {
  2.        
  3.         public static void main(String args[]) {
  4.             //overflow, because assign an integer to charcter.
  5.             char a=1;
  6.             char b=9;
  7.             System.out.println(a);
  8.             System.out.println(b);
  9.            
  10.             //correct assign
  11.             char c='1';
  12.             char d='9';
  13.             System.out.println(c);
  14.             System.out.println(d+"\n");
  15.            
  16.             //correct assign,
  17.             //and treat as a decimal number when being
  18.             //in the run time, this decimal number is
  19.             //defined in the ASCII table
  20.             char e='1';
  21.             char f='9';
  22.             System.out.println((int)e);
  23.             System.out.println((int)f);
  24.         }
  25. }