(Analysis of Class Library Use Cases) Use of StringBuffer

Define a StringBuffer class object, add 26 lowercase letters to the object through the append() method. It is required to add it only once at a time for a total of 26 times, and then output in reverse order, and 5 characters can be deleted.

 public static void main(String[] args) {
        StringBuffer stringBuffer = new StringBuffer();
        for(int x = 'a';x < 'z';x++){   //直接循环数组
            stringBuffer.append((char)x);
        }

        System.out.println(  stringBuffer.reverse().delete(0,4)); //反转处理并删除前五个字符2
    }

utsrqponmlkjihgfedcba

Guess you like

Origin blog.csdn.net/weixin_46245201/article/details/112724453