import java.util.Scanner;
public class Test7 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String arry;
String result="";
//获取键盘输入的字符串
Scanner sc = new Scanner(System.in);
arry=sc.nextLine();
//用正则表达式设定字符串范围
String regx1="[a-z]";
String regx2="[A-Z]";
for(int i=0;i<arry.length();i++)
{
String sub=arry.substring(i, i+1);
//判断是否是小写字母,是则转换为大写
if(sub.matches(regx1))
{
sub=sub.toUpperCase();
result+=sub;
}
//判断是否是小写字母,是则转换为小写
else if(sub.matches(regx2))
{
sub=sub.toLowerCase();
result+=sub;
}
//其他类型则直接输出
else
{
result+=sub;
}
}
System.out.println(result);
}
}
|