java uppercase方法_Java Character toUpperCase()方法

Java Character toUpperCase()方法

java.lang.Character.toUpperCase(int codePoint) 字符(Unicode代码点)参数使用来自UnicodeData文件的大小写映射信息转换为大写。

需要注意的是Character.isUpperCase(Character.toUpperCase(codePoint))某些范围内并不总是返回true字符,尤其是那些符号和象形文字。

1 语法

public static int toUpperCase(int codePoint)

2 参数

codePoint:转换字符(Unicode代码点)

3 返回值

此方法返回大写字符,如果有任何大写同等的字符;否则返回该字符本身。

4 示例

package com.yiidian;

/**

* 一点教程网: http://www.yiidian.com

*/

/**

* Java Character toUpperCase()方法

*/

import java.lang.*;

public class CharacterDemo {

public static void main(String[] args) {

// create 4 int primitives

int cp1, cp2, cp3, cp4;

// assign values to cp1, cp2

cp1 = 0x0072; // represents r

cp2 = 0x0569; // represents ARMENIAN SMALL LETTER TO

// assign uppercase of cp1, cp2 to cp3, cp4

cp3 = Character.toUpperCase(cp1);

cp4 = Character.toUpperCase(cp2);

String str1 = "Uppercase equivalent of " + cp1 + " is " + cp3;

String str2 = "Uppercase equivalent of " + cp2 + " is " + cp4;

// print cp3, cp4 values

System.out.println( str1 );

System.out.println( str2 );

}

}

输出结果为:

Uppercase equivalent of 114 is 82

Uppercase equivalent of 1385 is 1337

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值