「Java入門」java.lang.StringBuilder.replace()、reverse()、insert()のサンプル

1.java.lang.StringBuilder.replace()
StringBuilder sb=new StringBuilder(“Tokyo”);
sb.replace(1,3,”Osaka”);
System.out.println(sb); //TOsakayo

2.java.lang.StringBuilder.reverse()
StringBuilder sb=new StringBuilder(“hello world”);
sb.reverse();
System.out.println(sb);//dlrow olleh

3.java.lang.StringBuilder.delete()
StringBuilder sb=new StringBuilder(“Where”);
sb.delete(1,3);
System.out.println(sb);//Wre

4.java.lang.StringBuilder.insert()
StringBuilder sb=new StringBuilder(“Hello “);
sb.insert(1,”Test data”);
System.out.println(sb);//HTest dataello