public class StringExample { public static void main(String[] args) { String s = "Hello World!"; System.out.println("Original string: " + s); System.out.println("Length: " + s.length()); System.out.println("Uppercase: " + s.toUpperCase()); System.out.println("Lowercase: " + s.toLowerCase()); System.out.println("Substring from index 7: " + s.substring(7)); System.out.println("Replace 'o' with 'x': " + s.replace('o', 'x')); System.out.println("Contains 'world': " + s.contains("world")); System.out.println("Starts with 'Hello': " + s.startsWith("Hello")); System.out.println("Index of 'o': " + s.indexOf('o')); System.out.println("Last index of 'o': " + s.lastIndexOf('o')); System.out.println("Ends with 'ld!': " + s.endsWith("ld!")); System.out.println("Character at index 4: " + s.charAt(4)); System.out.println("Trimmed: " + s.trim()); } }