Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

printing default value of char

 
Loveleen Saroya
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

why it doesnt print anything?? but if i put the line //1 in the last then it prints y???
regards
Loveleen
 
anand phulwani
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
What i came to find out that its printing the default value of char
when i run the code with this




i got the following output

false
null
0
0.0



i got the following output
false
null
0
0.0



the difference is that it prints the space which remains unidentified,in the first code before 'false' and in the second after '0.0'
 
Sandeep Chhabra
Ranch Hand
Posts: 340
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

It is not printing anythin may be because the default value of char that is '\u0000' is not printable.
but if i put the line //1 in the last then it prints y???

for me it did not printed anything both in the last as well as in the first
it just prints a single space at both the places that's it.

Sandy
 
Sandeep Chhabra
Ranch Hand
Posts: 340
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I modified the code so that we can see wat the output is


output:
. .
false
null
0
0.0
. .

Sandy
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Various output "devices" print the character with value 0 in different ways. Some print nothing, some print some "funny" symbol indicating that they can't print a proper character. "Devices" include things like Windows command console windows and xterm windows as well as laser printers, teletypes, matrix printers, etc.
 
srikanth reddy
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Loveleen ..

iam using Jdev.when i executed the code its printing a symbol which represents like this []...in the first as well last instead of blank space as suggesting by our frnds .

why so??

thanks
srikanth
 
Sandeep Chhabra
Ranch Hand
Posts: 340
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by srikanth reddy:
hi Loveleen ..

iam using Jdev.when i executed the code its printing a symbol which represents like this []...in the first as well last instead of blank space as suggesting by our frnds .

why so??

thanks
srikanth


as Barry said...

Various output "devices" print the character with value 0 in different ways. Some print nothing, some print some "funny" symbol indicating that they can't print a proper character. "Devices" include things like Windows command console windows and xterm windows as well as laser printers, teletypes, matrix printers, etc.


this is the reason you are getting symbol.

Sandy
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic