Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

chars

 
Rajiv Chelsea
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



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
Posts: 15485
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Vinoth Kumar Kannan
Ranch Hand
Posts: 276
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh..the 'char' type is unsigned in java,is it??
 
Campbell Ritchie
Sheriff
Pie
Posts: 50241
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's all in the Java™ Language Specification; look for char, and it tells you whether it is signed or unsigned.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic