• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why is char doing strange things?

 
Vedhas Pitkar
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assume rest of code is correct & this is in a valid main().
char c=(char)-1;
System.out.println(c);//This prints ? (a question mark)
char d=(char)(Integer.MIN_VALUE);
System.out.println(d);//This causes the program to exit without any error or Exception .WHY??
Although this is not directly related to certification,I am plain curious.
Can anybody help?
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What part is confusing:

------------------
Tom - SCJP --- Co-Moderator of the Programmer Certification Forums
 
Bill Tripper
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Thomas Paul:
[B]What part is confusing:

[/B]

FWIW, On my Win NT box, I get the following:
c=?
D=Process Exit...
Bill

 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My results above were from running on a Win NT box. Curious!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic