This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes What happen if we print character '\u0000' Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "What happen if we print character Watch "What happen if we print character New topic
Author

What happen if we print character '\u0000'

Ramakrishna Nalla
Ranch Hand

Joined: Apr 21, 2005
Posts: 61



Program outputs nothing...

What is defalut value of char datatype..what happens if we print that char..
Waiting for your comments...
Cheers...
[ July 10, 2005: Message edited by: Barry Gaunt ]
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

See this ASCII table...

http://www.lookuptables.com/


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Ramakrishna Nalla
Ranch Hand

Joined: Apr 21, 2005
Posts: 61
I know ascii value of 0 is NULL...Please clearly explain me why... java unable to execute statements after this statement

char c=0;
System.out.println(c);//default value:'\u0000'
System.out.println("This will not print");

Thanks
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
It depends upon your output device. For me it prints:


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Ramakrishna Nalla:
... java unable to execute statements after this statement...

I tested your code with Java 5.0 in the Windows XP Command Prompt, and also in Mac 10.4.1 Terminal. In both cases, I get the same result as Barry posted above. The "null" char prints nothing, but does not cause any problems.

What environment are you running this in? Are you getting an error message?
Ramakrishna Nalla
Ranch Hand

Joined: Apr 21, 2005
Posts: 61
Thank U Very Much marc, editplus 2.12 is driven me in to mistake...by your suggestion i tested program in XP command it worked normally...By this experiance i known only command prompt is best for testing java programs...especially for SCJP...

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What happen if we print character '\u0000'
 
Similar Threads
JavaCaps Self Review Question -Section 1 Q6
default value for char?
how many differnt ways can you initialize char ....
char array
What happens when we print null character '\u0000' ?