if you’re talking Java String usage, there’s a ton of ways beyond the usual literal vs new String(). some of my go-to patterns:
String name = "Hilton"; String greeting = "Hello, " + name + "!"; // simple + String formatted = String.format("Hello, %s!", name); // cleaner for complex strings
StringBuilder sb = new StringBuilder(); sb.append("Java").append(" Strings").append(" rock"); String result = sb.toString();
String str = "apple,banana,cherry"; String[] fruits = str.split(","); // array of fruits String replaced = str.replace("banana", "orange"); String sub = str.substring(0, 5); // "apple"
str.equalsIgnoreCase("APPLE,BANANA,CHERRY"); // true str.startsWith("apple"); // true str.contains("banana"); // true
for(char c : str.toCharArray()){ System.out.println(c); }
basically, if you mix literals, builders, formatting, and regex, you can cover almost any string manipulation in Java without ever hitting performance issues.