Java Basics Part 12/20 - Character Class

Java Basics Part 12/20 - Character Class

目录


通常,处理字符时,都是用的原始类型 char。

举例:

char ch = 'a';

// Unicode for uppercase Greek omega character
char uniChar = '\u039A'; 

// an array of chars
char[] charArray ={ 'a', 'b', 'c', 'd', 'e' }; 

与 byte,int,long,double 等一样,char 也有自己的包装类 – Character。

Character提供了很多很有用的静态方法来操作字符。当然 Character 与 char 之间的装箱和拆箱技术就不赘述了。

举例:

// Here following primitive char 'a'
// is boxed into the Character object ch
Character ch = 'a';

// Here primitive 'x' is boxed for method test,
// return is unboxed to char 'c'
char c = test('x');

Character 的方法

SN Methods with Description
1 isLetter()
2 isDigit()
3 isWhiteSpace()
4 isUpperCase()
5 isLowerCase()
6 toUpperCase()
7 toLowerCase()
8 toString()
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章