📜  java字符串交换两个字符 - Java代码示例

📅  最后修改于: 2022-03-11 14:52:49.287000             🧑  作者: Mango

代码示例1
String originalString = "abcde";
//Strings are immutable
char[] c = originalString.toCharArray(); 
//Swap
char temp = c[0];
c[0] = c[1];
c[1] = temp;
//Result
String swappedString = new String(c);