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
You can also do this by using a temp variable but in a different way:
String a = "one" String b = "two" String temp = null; temp=a.concat(b); b=temp.substring(0,a.length()); a=temp.substring(a.length(),temp.length()); System.out.println("After Swapping A:"+a+"B:"+b);