it is because the filereader.read method only returns an int, which you capture on line 21, that corresponds to the ASCII table value of the character being read. When you output just 'a' the computer does not know 'a' is anything but an int. You need to cast to a char with the code you mentioned so that the computer outputs the character and not the ASCII number for the character.
http://www.asciitable.com/
publicclassSolution{publicstaticvoidmain(String[] args)throwsInterruptedException{for(int i =48; i <126; i++){System.out.println("Value of i: "+ i +", the ASCII character of i: "+(char) i);}}}
This website uses cookies to provide you with personalized service. By using this website, you agree to our use of cookies. If you require more details, please read our Terms and Policy.