android 字符串大小写转换
生活随笔
收集整理的這篇文章主要介紹了
android 字符串大小写转换
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
/*** 將給定字符串中給定的區(qū)域的字符轉(zhuǎn)換成小寫** @param str 給定字符串中* @param beginIndex 開始索引(包括)* @param endIndex 結(jié)束索引(不包括)* @return 新的字符串*/
public static String toLowerCase(String str, int beginIndex, int endIndex) {return str.replaceFirst(str.substring(beginIndex, endIndex),str.substring(beginIndex, endIndex).toLowerCase(Locale.getDefault()));
}
/*** 將給定字符串中給定的區(qū)域的字符轉(zhuǎn)換成大寫** @param str 給定字符串中* @param beginIndex 開始索引(包括)* @param endIndex 結(jié)束索引(不包括)* @return 新的字符串*/
public static String toUpperCase(String str, int beginIndex, int endIndex) {return str.replaceFirst(str.substring(beginIndex, endIndex),str.substring(beginIndex, endIndex).toUpperCase(Locale.getDefault()));
}
/*** 將給定字符串的首字母轉(zhuǎn)為小寫** @param str 給定字符串* @return 新的字符串*/
public static String firstLetterToLowerCase(String str) {return toLowerCase(str, 0, 1);
}
/*** 將給定字符串的首字母轉(zhuǎn)為大寫** @param str 給定字符串* @return 新的字符串*/
public static String firstLetterToUpperCase(String str) {return toUpperCase(str, 0, 1);
}
?
總結(jié)
以上是生活随笔為你收集整理的android 字符串大小写转换的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 系统集成项目管理工程师知识点总结(错题记
- 下一篇: 数据流通利用 | 数据产权研究综述