• Post Reply Bookmark Topic Watch Topic
  • New Topic

difference between char and character classes?  RSS feed

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could anyone help me understand if there is a difference between char and character in JAVA. There is a voice in the back of my head telling me there is. But I am not sure if I should listen or not
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nicholas Dorr wrote:Could anyone help me understand if there is a difference between char and character in JAVA. There is a voice in the back of my head telling me there is. But I am not sure if I should listen or not


The voice speaks the truth!

char is a primitive type that represents a single 16 bit Unicode character while Character is a "wrapper" class that allows us to use the char primitive concept in more of an OOP-kind of way, but with a small performance penalty (that can add up if you're doing a lot of calculations at one time).

For more on this, please look here:
data types
Wrapper Types
 
N Kol
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok how do i convert a char to uppercase, or .toUpperCase?
 
pete stein
Bartender
Posts: 1561
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
N Kol wrote:ok how do i convert a char to uppercase, or .toUpperCase?


The Character class has some static methods that will allow you to do this:

Character.toUpperCase(char c)

for one.
 
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also asked and answered here
http://www.coderanch.com/t/513130/java/java/char-toUpperCase
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!