将字符转换为大写 [英] Converting a char to uppercase
本文介绍了将字符转换为大写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
String lower = Name.toLowerCase();
int a = Name.indexOf(" ",0);
String first = lower.substring(0, a);
String last = lower.substring(a+1);
char f = first.charAt(0);
char l = last.charAt(0);
System.out.println(l);
如何获得F和L变量转换为大写。
how would i get the F and L variables converted to uppercase.
推荐答案
您可以使用 Character#toUpperCase()
。
You can use Character#toUpperCase()
for this.
char fUpper = Character.toUpperCase(f);
char lUpper = Character.toUpperCase(l);
它有一些限制,因为世界知道更多的字符, code> char 范围。另请参阅以下摘录 javadoc :
It has however some limitations since the world is aware of many more characters than can ever fit in 16bit char
range. See also the following excerpt of the javadoc:
注意:此方法无法处理补充字符。要支持所有Unicode字符(包括补充字符),请使用
toUpperCase(int)
方法。
Note: This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the
toUpperCase(int)
method.
这篇关于将字符转换为大写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文