This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What happen if we print character '\u0000'

 
Ramakrishna Nalla
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



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
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See this ASCII table...

http://www.lookuptables.com/
 
Ramakrishna Nalla
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It depends upon your output device. For me it prints:
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic