Java-StringBuilder-insert-example.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package info.goyun; | |
public class StringBuilderDemo { | |
public static void main(String[] args) { | |
StringBuilder str = new StringBuilder("Go.info"); | |
System.out.println("string = " + str); | |
// insert character value at offset 2 | |
str.insert(2, "Yun"); | |
// prints StringBuilder after insertion | |
System.out.print("After insertion = "); | |
System.out.println(str.toString()); | |
//output: After insertion = GoYun.inf | |
} | |
} |
Comments
Post a Comment