How do I swap two string variables in Java without using a third variable, i.e. the temp variable?
String a = \"one\" String b = \"two\" String temp = null; temp
String a="one"; String b="two"; a = a.concat("#" + b); b = a.split("#")[0]; a = a.split("#")[1];
This will work as long as your string doesn't contain the # character in them. Feel free to use any other character instead.
You could use a possible Unicode character, like "\u001E" instead of the #.