如何对字母大小写进行转换? 具体是怎么实现的呢,我如何才能看见其源代码? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public String toUpperCase(Locale locale) { int len = count; int off = offset; char[] val = value; int firstLower; /* Now check if there are any characters that need changing. */ scan: { char upperCaseChar; char c; for (firstLower = 0 ; firstLower < len ; firstLower++) { c = value[off+firstLower]; upperCaseChar = Character.toUpperCaseEx(c); if (upperCaseChar == Character.CHAR_ERROR || c != upperCaseChar) { break scan; } } return this; } char[] result = new char[len]; /* might grow! */ int resultOffset = 0; /* result grows, so i+resultOffset * is the write location in result */ /* Just copy the first few upperCase characters. */ System.arraycopy(val, off, result, 0, firstLower); if (locale.getLanguage().equals("tr")) { // special loop for Turkey char[] upperCharArray; char upperChar; char ch; for (int i = firstLower; i < len; ++i) { ch = val[off+i]; if (ch == 'i') { result[i+resultOffset] = '\u0130'; // dotted cap i continue; } if (ch == '\u0131') { // dotless i result[i+resultOffset] = 'I'; // cap I continue; } upperChar = Character.toUpperCaseEx(ch); if (upperChar == Character.CHAR_ERROR) { upperCharArray = Character.toUpperCaseCharArray(ch); /* Grow result. */ int mapLen = upperCharArray.length; char[] result2 = new char[result.length + mapLen - 1]; System.arraycopy(result, 0, result2, 0, i + 1 + resultOffset); for (int x=0; x<mapLen; ++x) { result2[i+resultOffset++] = upperCharArray[x]; } --resultOffset; result = result2; } else { result[i+resultOffset] = upperChar; } } } else { // normal, fast loop char[] upperCharArray; char upperChar; char ch; for (int i = firstLower; i < len; ++i) { ch = val[off+i]; upperChar = Character.toUpperCaseEx(ch); if (upperChar == Character.CHAR_ERROR) { upperCharArray = Character.toUpperCaseCharArray(ch); /* Grow result. */ int mapLen = upperCharArray.length; char[] result2 = new char[result.length + mapLen - 1]; System.arraycopy(result, 0, result2, 0, i + 1 + resultOffset); for (int x=0; x<mapLen; ++x) { result2[i+resultOffset++] = upperCharArray[x]; } --resultOffset; result = result2; } else { result[i+resultOffset] = upperChar; } } } return new String(0, result.length, result); } 子类方法为什么不能低于超类方法的可见性 XStream ToXML 中如何添加属性 类怎么定义 如何得知一个实例在初始化的时候是否使用了类型参数 java怎么 画虚线矩形? 新手学java,请教一个简单的问题 求:思路!非诚勿扰,谢谢! 取当前月天数的问题 一个日期格式转换的问题 继承JDesktopPanel的画面 如何迁移画面 [在线等待] JAVA应用程序界面编程高手请进:)一个做java的软件公司的面食问题。 postgresql的jdbc不 能使用请问那位清楚谢谢. java中连接sqlserver的问题
int len = count;
int off = offset;
char[] val = value;
int firstLower; /* Now check if there are any characters that need changing. */
scan: {
char upperCaseChar;
char c;
for (firstLower = 0 ; firstLower < len ; firstLower++) {
c = value[off+firstLower];
upperCaseChar = Character.toUpperCaseEx(c);
if (upperCaseChar == Character.CHAR_ERROR || c != upperCaseChar) {
break scan;
}
}
return this;
} char[] result = new char[len]; /* might grow! */
int resultOffset = 0; /* result grows, so i+resultOffset
* is the write location in result */ /* Just copy the first few upperCase characters. */
System.arraycopy(val, off, result, 0, firstLower); if (locale.getLanguage().equals("tr")) {
// special loop for Turkey
char[] upperCharArray;
char upperChar;
char ch; for (int i = firstLower; i < len; ++i) {
ch = val[off+i];
if (ch == 'i') {
result[i+resultOffset] = '\u0130'; // dotted cap i
continue;
}
if (ch == '\u0131') { // dotless i
result[i+resultOffset] = 'I'; // cap I
continue;
}
upperChar = Character.toUpperCaseEx(ch);
if (upperChar == Character.CHAR_ERROR) {
upperCharArray = Character.toUpperCaseCharArray(ch);
/* Grow result. */
int mapLen = upperCharArray.length;
char[] result2 = new char[result.length + mapLen - 1];
System.arraycopy(result, 0, result2, 0,
i + 1 + resultOffset);
for (int x=0; x<mapLen; ++x) {
result2[i+resultOffset++] = upperCharArray[x];
}
--resultOffset;
result = result2;
}
else {
result[i+resultOffset] = upperChar;
}
}
} else {
// normal, fast loop
char[] upperCharArray;
char upperChar;
char ch;
for (int i = firstLower; i < len; ++i) {
ch = val[off+i];
upperChar = Character.toUpperCaseEx(ch);
if (upperChar == Character.CHAR_ERROR) {
upperCharArray = Character.toUpperCaseCharArray(ch);
/* Grow result. */
int mapLen = upperCharArray.length;
char[] result2 = new char[result.length + mapLen - 1];
System.arraycopy(result, 0, result2, 0,
i + 1 + resultOffset);
for (int x=0; x<mapLen; ++x) {
result2[i+resultOffset++] = upperCharArray[x];
}
--resultOffset;
result = result2;
}
else {
result[i+resultOffset] = upperChar;
}
}
}
return new String(0, result.length, result);
}