File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Printing a character Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Printing a character " Watch "Printing a character " New topic
Author

Printing a character

Tarun Oohri
Ranch Hand

Joined: Feb 20, 2013
Posts: 180
Hello Everyone
Can anyone explain why the output is coming out to be blank in the following code.Thanks!!!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
The 0x000a char is the linefeed character, so you would expect to get two blank lines before 10 is printed. Your code prints:-


10
and System.out.println(); System.out.println((int)d); prints one blank line:-

10
Tarun Oohri
Ranch Hand

Joined: Feb 20, 2013
Posts: 180
Campbell Ritchie wrote:The 0x000a char is the linefeed character, so you would expect to get two blank lines before 10 is printed. Your code prints:-


10
and System.out.println(); System.out.println((int)d); prints one blank line:-

10

Thanks Campbell for your reply but i am not able to get you...What is "0x000a" ? From where it came ? Is it a uni code of number 10 ?
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11499
    
  16

0x000a is the hexadecimal representation of the decimal number 10. It's just a different way to write same number. "ten", "10", X (roman numeral), 1010 (binary), 12 (octal) are all different ways to represent the same concept of ten.

So what do you expect to print out? you defined 'd' to be a char type. that means it represent a character. If you look at the ascii chart, you can see that 10 as a character is a line feed. In the old days, that would advance the paper one line. On a terminal, it moves the cursor down one line.

It IS printing...it is just not printing what you think it should.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Tarun Oohri
Ranch Hand

Joined: Feb 20, 2013
Posts: 180
Thanks fred for makng it more clear...got it this time ...
Cheers!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Printing a character