This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes printing default value of char Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "printing default value of char" Watch "printing default value of char" New topic
Author

printing default value of char

Loveleen Saroya
Ranch Hand

Joined: Aug 08, 2005
Posts: 42

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

Joined: Sep 10, 2005
Posts: 242
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'


Thanks and Regards, Anand
SCJP 5.0 310-055 73%, SCWCD 1.4 310-081 78%, IBM DB2 9 Fundamentals 000-730 62%
Sandeep Chhabra
Ranch Hand

Joined: Aug 28, 2005
Posts: 340
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


Regards<br />Sandy<br />[SCJP 5.0 - 75%]<br />[SCWCD 1.4 - 85%]<br />------------------<br />Tiger, Tiger burning bright,<br />Like a geek who works all night,<br />What new-fangled bit or byte,<br />Could ease the hacker's weary plight?
Sandeep Chhabra
Ranch Hand

Joined: Aug 28, 2005
Posts: 340
I modified the code so that we can see wat the output is


output:
. .
false
null
0
0.0
. .

Sandy
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
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.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
srikanth reddy
Ranch Hand

Joined: Jul 28, 2005
Posts: 252
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


Thanks & Regards<br /> <br />-Srikanth
Sandeep Chhabra
Ranch Hand

Joined: Aug 28, 2005
Posts: 340
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
 
Don't get me started about those stupid light bulbs.
 
subject: printing default value of char