How to swap two string without using a thrid variable?

Use the following code to swap two strings without using a third variable.

public void swapStr(String a,String b) {  
    a = b + a;
    b = a.replace(b, "");
    a = a.replace(b, "");
   
    System.out.println(a+","+b);
}

public void swapString(String a,String b) {  
            a = b + a;
            b = a.substring(b.length());
            a = a.replaceAll(b, "");
           
            System.out.println(a+","+b);
        }
       

Interview Questions: 

Search