Recently I have given an interview where they have asked me to swap two String without using any third variable and without using any String method like substring, replace or without using StringBuilder
and StringBuffer
.
Eg:
String str1 = "hello";
String str2 = "morning";
output:
String str1 = "morning";
String str2 = "hello";