aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes why is char doing strange things? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "why is char doing strange things?" Watch "why is char doing strange things?" New topic
Author

why is char doing strange things?

Vedhas Pitkar
Ranch Hand

Joined: Jan 27, 2001
Posts: 445
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

Joined: May 05, 2000
Posts: 13974
What part is confusing:

------------------
Tom - SCJP --- Co-Moderator of the Programmer Certification Forums


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Bill Tripper
Greenhorn

Joined: May 30, 2001
Posts: 24
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

Joined: May 05, 2000
Posts: 13974
My results above were from running on a Win NT box. Curious!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why is char doing strange things?
 
Similar Threads
danchisholm.net august09 comprehensive exam4.Q9
primitive char and unicode value assignments
Arrays
char literals
bitwise & operation on char variable