例如:
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);
}}

解决方案 »

  1.   

    楼主这样还不如用byte[],然后一个一个判断并转换
    当然stringbuffer也是相同的做法
      

  2.   

    这样试试吧,可以完成转化。
    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());
    }
    }
      

  3.   


    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);
    }
    }