Write a Java Program to Swap Strings using temp variable

By | March 2, 2017

Java Program to Swap Strings


 

Given two strings, we have to swap strings. For example, If First String = “ABC” and Second String = “abc” then after swapping First String = “abc” and Second String = “ABC”.

To swap strings in Java Programming, you have to first ask to the user to enter the two string, then make a temp variable of the same type. Now place the first string in the temp variable, then place the second string in the first, now place the temp string in the second.

Following Java Program ask to the user to enter the two strings to swap the strings, then display the result after swapping the strings:


SOURCE CODE : :

 

 

OUTPUT : :

 

 

Leave a Reply