怎么样实现大小写转换?

public String charConvert(String str){

  char[] chs = str.toCharArray();

  for(int i = 0; i < str.length(); i++){

    if((int)chs[i] >= 65 && (int)chs[i] <= 90){

      chs[i]=(char)((int)chs[i] + 32);

    }else{

      chs[i]=(char)((int)chs[i] - 32);

    }

  }

  String s = new String(chs);

  return s;

}

猜你喜欢

转载自www.cnblogs.com/huangzhixin/p/9373793.html
今日推荐