Posts

Showing posts from September, 2025

JAVA PROGRAMS

 2(c). JAVA program that demonstrates how to use StringBuffer to delete and remove characters. public class StringBufferExample {     public static void main(String[] args) {         // Create a StringBuffer object         StringBuffer sb = new StringBuffer("Hello, World!");         System.out.println("Original StringBuffer content: " + sb);         // Delete characters from index 5 to 7         sb.delete(5, 7);         System.out.println("After deleting characters from index 5 to 7: " + sb);         // Delete a character at index 5         sb.deleteCharAt(5);         System.out.println("After deleting character at index 5: " + sb);     } } This program: 1. Creates a StringBuffer object with the string "Hello, World!". 2. Prints the original content of the StringBuffer. 3. Uses the del...