How can I swap two characters in a String? For example, \"abcde\" will become \"bacde\".
String
\"abcde\"
\"bacde\"
'In' a string, you cant. Strings are immutable. You can easily create a second string with:
String second = first.replaceFirst("(.)(.)", "$2$1");