例如:
public class StringBufferExample {
public static void main(String[] args) {
StringBuffer yourStr=new StringBuffer("i Love ThIS GaME");
//(把大写改成小写 而且小写改成大写(I lOVE tHis gAme))
System.out.println(yourStr);
}}
public class StringBufferExample {
public static void main(String[] args) {
StringBuffer yourStr=new StringBuffer("i Love ThIS GaME");
//(把大写改成小写 而且小写改成大写(I lOVE tHis gAme))
System.out.println(yourStr);
}}
当然stringbuffer也是相同的做法
public class StringBufferExample {
public static void main(String[] args) {
StringBuffer yourStr = new StringBuffer("i Love ThIS GaME");
String str = yourStr.substring(0, yourStr.length());
// (把大写改成小写 而且小写改成大写(I lOVE tHis gAme))
System.out.println(str.toLowerCase());
System.out.println(str.toUpperCase());
}
}
public class StringBufferExample{
public static void main(String[] args){
StringBuffer yourStr=new StringBuffer("i Love ThIS GaME");
String str = yourStr.toString();
String[] a = str.split("");
String b = "";
for(int i=0;i<a.length;i++){
int c = a[i].hashCode();
if(c>=97 && c<=122){
a[i] = a[i].toUpperCase();
}
if(c>=65 && c<=90){
a[i]=a[i].toLowerCase();
}
b= b+a[i];
}
System.out.println(b);
}
}