首页 > 其他 > 详细

大小写转换

时间:2015-02-22 14:36:03      阅读:352      评论:0      收藏:0      [点我收藏+]

技术分享



import java.util.*;
import java.io.*;
public class 大小写转换 {


/**
* @param args
*/
public static void main(String[] args) {
Scanner in=new Scanner(new BufferedInputStream(System.in));
while(in.hasNext()){
String str=in.next(); //输入字符串
char[] arr = str.toCharArray(); //转换成数组
for (int i = 0; i < arr.length; i++){
int temp =arr[i];
if (temp<=‘Z‘ && temp>=‘A‘){
arr[i]=(char)(temp + 32); //变小写
}
else if(temp <=‘z‘ && temp >=‘a‘){
arr[i]=(char)(temp - 32); //变大写
}
}
for(int i=0;i<arr.length;i++){
System.out.print(arr[i]);
}
}
}


}






大小写转换

原文:http://blog.csdn.net/a736933735/article/details/43907363

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!