How to swap two String values without using a
third variable?

Answer Posted / badar awan

public class B
{
public static void main(String [] args)
{
String a = "Badar" ;
String b ="Asad";
a= a+b;
b = a.substring(0,(a.length()-b.length()));
a = a.substring(b.length(),(a.length()));
System.out.println("a == "+ a);
System.out.println("b == "+ b);
}
}

Is This Answer Correct ?    9 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a program to reverse a number?

655


Difference between delegates and Events?

1712


what is the difference between uservariables and systemvariables (in Environmental variables)???

1935


what is diff bet ref variable & instance of class

1546


I am taking the bmc control m/enterprise manager 7.0 scheduling test and just wanted to see what kind of questions they would ask or if anyone has taken the test and how long it is for how many questions?

5662






What is the use of Differ interface check box in Ship confirm?

1842


Hi All, Can any one please send me the difference between informatica 7i and 8i versions, Thanks in advance. vinod

1533


Q2. A memory location has physical address D5687h. Compute: a. The offset address if the segment number is D445h. b. The segment number if the offset address is B577h.

1628


any drawback are there in mantis?

1642


hi viewers, tell me,what is scripting and programming, define and difference...pls

1500


what is the meaning of without standing arrears?

9859


What r the attributes using in Win Runner?

1948


how to work search engine? plz detail answer me.

1485


What is autocall macro and how to create autocall macro? what is the use of it?

1491


Given a set. Write the pseudo code to get all the subsets for the given set. Eg. Input : {1,2} Output : (),(1),(2),(1,2)

2226