首字母大写转换 java,Java InitialsTransformation(字符串首字母大小写转换)
版權(quán)聲明:本文為原創(chuàng)博文,最終解釋權(quán)歸一個(gè)集 帥氣 與 智慧 和 手速 于一身的男人-滅世奶神-所有!- - - - - - - - - - - - -轉(zhuǎn)載:請(qǐng)附上--源作者 / 源博文--相關(guān)鏈接信息! https://blog.csdn.net/qq_36823679--------------------- https://blog.csdn.net/qq_36823679/article/details/90489357
[code]//package Main;
/**
*
* @Explain(說(shuō)明):字符串首字母大小寫轉(zhuǎn)換工具類
* @time(時(shí)間):2019/04/17
* @role(誰(shuí)):東方神祇(楊)
* @role(誰(shuí)):東方神祇(楊)
*
* @modify(修改)
* @time:
* @role:
*/
public class InitialsTransformation {
public static void main(String[] args) {
System.out.println(StringUtilMax.initcap("yangmufa")) ;
System.out.println(StringUtilMin.initcap1("YANGMUFA")) ;
}
}
class StringUtilMax{
public static String initcap(String str){
//如果字符串str為null和""則返回原數(shù)據(jù)
if (str==null||"".equals(str)){
return str ;
}
if(str.length()==1){
//如果字符串str的長(zhǎng)度為1,則調(diào)用專門把字符串轉(zhuǎn)換為大寫的string方法tuUpperCase()
return str.toUpperCase() ;
}
//用字符串截取方法subString()截取第一個(gè)字符并調(diào)用toUpperCase()方法把它轉(zhuǎn)換為大寫字母
//再與從str第二個(gè)下標(biāo)截取的字符串拼接
return str.substring(0,1).toUpperCase()+str.substring(1) ;
}
}
class StringUtilMin{
public static String initcap1(String str){
//如果字符串str為null和""則返回原數(shù)據(jù)
if (str==null||"".equals(str)){
return str ;
}
if(str.length()==1){
//如果字符串str的長(zhǎng)度為1,則調(diào)用專門把字符串轉(zhuǎn)換為小寫的string方法tuUpperCase()
return str.toLowerCase() ;
}
//用字符串截取方法subString()截取第一個(gè)字符并調(diào)用toUpperCase()方法把它轉(zhuǎn)換為小寫字母
//再與從str第二個(gè)下標(biāo)截取的字符串拼接
return str.substring(0,1).toLowerCase()+str.substring(1) ;
}
}
總結(jié)
以上是生活随笔為你收集整理的首字母大写转换 java,Java InitialsTransformation(字符串首字母大小写转换)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 移动场景在其缩略图中显示场景中所显示的区
- 下一篇: 设计java application程序