怎么样实现大小写转换?

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;

}

posted @ 2018-07-26 19:15  huangzhixin  阅读(135)  评论(0编辑  收藏  举报