Java中的char和Character之间有什么区别? [英] What is the difference between char and Character in Java?

查看:726
本文介绍了Java中的char和Character之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道在Java中的char和Character之间的区别是什么,因为当我在做一个java程序时,char工作时字符不工作。



char,

的示例

  char ch ='a'; 

角色示例,

  Character.toUpperCase(ch); 

将'a'转换为'A'


I need to know what is the difference between char and Character in Java because when I was making a java program, the char worked while the Character didn't work.

解决方案

char is a primitive type that represents a single 16 bit Unicode character while Character is a wrapper class that allows us to use char primitive concept in OOP-kind of way.

Example for char,

char ch = 'a';

Example of Character,

Character.toUpperCase(ch);

It converts 'a' to 'A'

这篇关于Java中的char和Character之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆