
Hi,
can any one tell me the code to swap the 2 strings without using temporary varibales???
Thanks a lot in advance!!

Here is an example that prompts the user to enter two string and then swaps both the string without using third variable.
import java.util.*;
class SwapTwoStringsWithoutUsingThirdVariable
{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
System.out.print("Enter string1: ");
String st1=input.next();
System.out.print("Enter string2: ");
String st2=input.next();
System.out.println();
System.out.println("Before swapping:");
System.out.println("st1="+st1+" and st2="+st2);
st1=st1+st2;
st2 = st1.substring(0,(st1.length()-st2.length()));
st1 = st1.substring(st2.length(),(st1.length()));
System.out.println();
System.out.println("After swapping:");
System.out.println("st1="+st1+" and st2="+st2);
}
}