How to Swap two string without using a third variable and predefined functions in Java?

Someone asked me this Question that how to swap 2 String variables. This is quiet simple by taking 3rd variable. But he said no i can’t use any third variable. Then i found a way by using predefined functions of Java (by using split function). But again he said i can”t use any predefined function. After thinking for a while i finally thought that there must be a  complex logic. But i was shocked when he showed me the code to do this. I though to sharing that piece of code with you guys .

 

Be the first to comment

Leave a Reply

Your email address will not be published.


*