package J20250715.stringbuider;

/**
 * @author WanJl
 * @version 1.0
 * @title Demo02
 * @description
 * @create 2025/7/15
 */
public class Demo02 {
    public static void main(String[] args) {
        //创建StringBuilder可变字符串对象--无参数
        StringBuilder sb=new StringBuilder();
        System.out.println("sb："+sb);
        System.out.println("sb.length() :"+sb.length());

        //创建StringBuilder可变字符串对象--有参数
        StringBuilder sb1=new StringBuilder("hello world");
        System.out.println("sb1："+sb1);
        System.out.println("sb1.length() :"+sb1.length());

        //调用StringBuilder追加字符串的方法 append(任意类型);
        sb.append("今天");
        sb.append("是个");
        sb.append("好天气");
        System.out.println("sb："+sb);
        System.out.println("sb.length() :"+sb.length());

        //调用方法实现字符串反转
        sb.reverse();
        System.out.println("字符串反转："+sb);
    }
}
