Java 字符串变形

例如:"Ni Hao Katherine"变形之后就变成了"nI hAO kATHERINE"

public class Test {
	public static void main(String[] args) {
		String s = "Ni Hao Katherine";
		String str = "";
		for(int i = 0,len = s.length();i= 'A' && c <= 'Z'?(c+32):(c-32));
			}
			str = str + c;
		}	
		System.out.println(str);
		//第二步:单词反转	
		String word = "";
		String ret = "";
		
		for(int i = 0,len = str.length();i

首先获取当前字符,再单词反转,输出单词

运行结果

nI hAO kATHERINE
kATHERINE hAO nI 

你可能感兴趣的:(java,开发语言)