Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a5987ef

Browse files
Swap two strings
1 parent 62d5304 commit a5987ef

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

‎InterviewPrograms/src/com/java/strings/SwapTwoStrings.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
/*
66
* Swap Two Strings without using third variable
7+
* ---------------------------------------------
78
* Say String1 is : good
89
* Say String2 is : bad
910
* The output should print string1 is bad and string2 is good
1011
*
1112
*/
1213

1314
public class SwapTwoStrings {
14-
1515
public static void main(String[] args) {
1616
Scanner scanner = new Scanner(System.in);
1717
System.out.println("Enter the String 1 : ");
@@ -23,7 +23,7 @@ public static void main(String[] args) {
2323
str2 = str1.substring(0,str1.length()-str2.length());
2424
str1 = str1.substring(str2.length());
2525

26-
System.out.println("After swapping--");
26+
System.out.println("After swapping ::");
2727
System.out.println("String 1 is : "+str1);
2828
System.out.println("String 2 is : "+str2);
2929
scanner.close();
@@ -33,13 +33,13 @@ public static void main(String[] args) {
3333
OUTPUT
3434
Enter the String 1 : good
3535
Enter the String 2 : bad
36-
After swapping--
36+
After swapping::
3737
String 1 is : bad
3838
String 2 is : good
3939
4040
Enter the String 1 : hello
4141
Enter the String 2 : world
42-
After swapping--
42+
After swapping::
4343
String 1 is : world
4444
String 2 is : hello
4545
*/

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /