Skip to content

Commit a91f3d9

Browse files
authored
Create SBDemo3.java
1 parent ac34ca3 commit a91f3d9

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

SBDemo3.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Demonstration of StringBuffer {insert, setCharAt, setLength}
2+
3+
class SBDemo3{
4+
public static void main(String args[]){
5+
StringBuffer sb1 = new StringBuffer("My Java");
6+
System.out.println("Adding the word : " + sb1.insert(3,"Core")); // My CoreJava
7+
8+
StringBuffer sb2 = new StringBuffer("Japan");
9+
sb2.setCharAt(2,'k');
10+
System.out.println("Changed character : " + sb2); // Jakan
11+
12+
StringBuffer sb3 = new StringBuffer("Computer");
13+
sb3.setLength(4);
14+
System.out.println("Cutting the length : " + sb3); // Comp
15+
}
16+
}

0 commit comments

Comments
 (0)