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
Actually, the code in your question did not swap String a,b.
You should see this issue: Swap two strings in Java, by passing them to a utility function, but without returning objects or using wrapper classes
And Java is passing by value: Is Java "pass-by-reference" or "pass-by-value"?