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 2

3 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 d

e 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

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -