How to swap two strings without using the third variable in java?
The logic that can be implemented for this program is as follow: Step1: Concatenate both strings and store them in the first variable. Ex. s1 = s1 + s2 Step2: s2 = s1.substring(0, s1.length() – s2.length()); Step3: s1 = s1.substring(s2.length()); Solution Let’s see the complete logic below: SwapTwoString.java OUTPUT: Before swap :: s1=>abc, s2=>xyz123After swap …
How to swap two strings without using the third variable in java? Read More »