Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

code output  RSS feed

 
Claude Cundiff
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys, I've been looking at the following website for some good I/O examples.

http://www.cafeaulait.org/books/javaio2/

Here is the code:



When I run this program and type in "1", I get this output:
49
13
10

I don't understand this. If you could shed some light on this, I'd greatly appreciate it.
 
Rob Spoor
Sheriff
Posts: 21088
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The ASCII code of '1' is 49. The following 13 and 10 are carriage return (\r) and new line (\n). See http://www.asciitable.com/

To print the '1', cast the int to a char and then print it.
 
Claude Cundiff
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rob!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!