aspose file tools*
The moose likes Beginning Java and the fly likes chars Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "chars" Watch "chars" New topic
Author

chars

Rajiv Chelsea
Ranch Hand

Joined: Jun 15, 2010
Posts: 88



How is it possible to assign 65 to ch which is a char?
As i know char values shuld be enclosed in single quotes
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14150
    
  18

Because char is really a numeric type, that can contain values between 0 and 65535.

The 65 is an integer literal, but according to the Java specification it can be assigned to a char using a narrowing primitive conversion if the number fits in the char.

The Unicode code point for the capital letter A is 65.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Vinoth Kumar Kannan
Ranch Hand

Joined: Aug 19, 2009
Posts: 276

oh..the 'char' type is unsigned in java,is it??


OCPJP 6
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38840
    
  23
It's all in the Java™ Language Specification; look for char, and it tells you whether it is signed or unsigned.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: chars