java - Cannot comprehend Output Of The Program -


import java.util.scanner; public class asdf {     public static void main(){      string temp = "165";      int ch = temp.charat(0);      int ch1 = temp.charat(1);      int ch2 = temp.charat(2);      system.out.println(ch);      system.out.println(ch1);      system.out.println(ch2);     }  } output: 49 54 53 

i cannot understand output.is implicit cast according character converted number . appreciated.

it printing ascii values of digits. 1,6,5.

note ascii value of 0 48. so, 49 ascii value of character 1 , on.

have here: http://www.asciitable.com/

try actual characters printed instead of ascii values:

char ch = temp.charat(0); char ch1 = temp.charat(1); char ch2 = temp.charat(2); 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -