java - Integer to char - cast and print: -
i want know logic behind programm , (char
) cast. how work , how printing letters, symbols , numbers
package ascii1 public class ascii1 { public static void main(string[] args) { int i=1; while(i<122) { system.out.println((char)i+"\t"); if (i%10==0) system.out.println(""); i++; } } }
its output is:
//blanks in beginning...
! "
$ % & ' (
) * + ,
- . / 0 1 23 4 5 6 7 8 9 : ; <
=
? @ b c d e f
g h j k l m n o p
q r s t u v w x y z
[ \ ] ^
_ ` b c de f g h j k l m n
o p q r s t u v w x
y build successful (total time: 0 seconds)
using ascii
representation, every char has numerical value.
when iterate, adding +1
i
variable, numbers on ascii
table representing characters.
finally, (char)
cast returns above ascii
character.
Comments
Post a Comment