
4.20 Simple IO and Arrays and String Vectors
17. System.out.println(“Modifying few elements of String”);
18. stg.setCharAt(0,’o’);
19. stg.setCharAt(1,’o’);
20. stg.setCharAt(2,’p’);
21. stg.setCharAt(3,’s’);
22. System.out.println(“String after modifications”);
23. System.out.println(stg);
24. System.out.println(“Appending String”);
25. stg.append(“ Languages”);
26. System.out.println(“String after appending”);
27. System.out.println(stg);
28. }//end of main
29. }//end of class StringBufferDemo
Output: Given String : C++ & Java
Printing Given String character by character
C + + & J a v a
Inserting a string :OOPS in: at the begining
String after ...