How can I swap two characters in a String? For example, \"abcde\" will become \"bacde\".
String
\"abcde\"
\"bacde\"
The following line of code will swap the first two characters in str:
str
return str.charAt(1) + str.charAt(0) + str.substring(2);