Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

code output

 
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: 20822
68
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!
 
Run away! Run away! Here, take this tiny ad with you:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!