Java将字符串的首字母转换大小写

//首字母转小写
public static String toLowerCaseFirstOne(String s){
  if(Character.isLowerCase(s.charAt(0)))
    return s;
  else
    return (new StringBuilder()).append(Character.toLowerCase(s.charAt(0))).append(s.substring(1)).toString();
}


//首字母转大写
public static String toUpperCaseFirstOne(String s){
  if(Character.isUpperCase(s.charAt(0)))
    return s;
  else
    return (new StringBuilder()).append(Character.toUpperCase(s.charAt(0))).append(s.substring(1)).toString();
}

posted @ 2017-05-09 13:37  浪里小白龙呼呼呼  阅读(41983)  评论(0编辑  收藏  举报