// String creation
String str1 = "Hello";
String str2 = new String("World");

// Concatenation
String combined = str1 + " " + str2; // "Hello World"
String withConcat = str1.concat(" Java"); // "Hello Java"

// Length
int length = str1.length(); // 5

// Character access
char first = str1.charAt(0); // 'H'

// Substring
String sub1 = str1.substring(1);     // "ello"
String sub2 = str1.substring(1, 4);  // "ell"

// Search
boolean contains = str1.contains("ell"); // true
int index = str1.indexOf('l');            // 2
int lastIndex = str1.lastIndexOf('l');     // 3
boolean startsWith = str1.startsWith("He"); // true
boolean endsWith = str1.endsWith("lo");    // true

// Replace
String replaced = str1.replace('l', 'L');        // "HeLLo"
String replacedAll = str1.replaceAll("l", "L"); // "HeLLo"
String replacedFirst = str1.replaceFirst("l", "L"); // "HeLlo"

// Case conversion
String upper = str1.toUpperCase(); // "HELLO"
String lower = upper.toLowerCase(); // "hello"

// Split
String text = "one,two,three";
String[] parts = text.split(","); // ["one", "two", "three"]

// Trim
String withSpaces = "  Hello  ";
String trimmed = withSpaces.trim(); // "Hello"

// Format
String formatted = String.format("Name: %s, Age: %d", "Alice", 30);
// "Name: Alice, Age: 30"

// StringBuilder for efficient concatenation
StringBuilder sb = new StringBuilder();
sb.append("Hello");
sb.append(" ");
sb.append("World");
String result = sb.toString(); // "Hello World"

// String comparison
boolean equals = str1.equals("Hello"); // true
boolean equalsIgnoreCase = str1.equalsIgnoreCase("HELLO"); // true
int compare = str1.compareTo("World"); // negative value

// Check empty
boolean isEmpty = str1.isEmpty(); // false
boolean isBlank = "   ".trim().isEmpty(); // true