Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Answer Posted / gayitri91

import java.io.*;

class Swap_2_Strings
{
String s1,s2;
DataInputStream dis=new DataInputStream(System.in);


Swap_2_Strings()
{
try
{
int n,m;
System.out.println("Enter 2 strings");
s1=dis.readLine();
s2=dis.readLine();
n=s1.length();
m=s2.length();
s1=s1+s2;
s2=s1.substring(0,n);

s1=s1.substring(n,n+m);

System.out.println("s1="+s1+"\n s2="+s2);

}
catch(IOException x)
{
System.out.println(x);
}
}
public static void main(String arg[])
{
Swap_2_Strings s=new Swap_2_Strings();
}
}

Is This Answer Correct ?    7 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to call a C++ function which is compiled with C++ compiler in C code?

1264


diffrence between oracle apps , .NET , SAP

2070


what are the missinschema properties and should we pass primary key in select command

1820


is it possible to learn sap from book without any tutorial. if yes please mention the beginner,s book of sap and also make your valuable advice for self study of sap .

1948


Write a program to find whether a given number is prime or not.

977


in IBM PC -AT.WAT AT REFERS TO?

1853


1.how to deploy the Maven application in weblogic server? 2.In Real time projects all classes are singleton or some classes only singleton explain? 3.what are the major uses of the designpatterns? 4.explain restful &Soap based services explain?

2131


Always use scope terminator like End-If with IF, End- Evaluate with Evaluate statement.Can somebody explain me the detail logical explanation?

1945


I am looking for selenium RC online Training in chennai. can any one tell me the best institute

1926


How to create a new dataset only duplicate observations in proc sort procedure?

1973


hai i am mca 2009 fresher.please tell me which certification helps me to get an IT job faster which institute is good in hyderabad.please mail me to prasanna.1856@rediff.com

1922


Why did you ever become involved in QA/testing?

1996


Plz sent me in .net 2.0 interview Question & answers?

2090


Describe the difference between Interface-oriented, Object-oriented and Aspect-oriented programming

11894


In OB52 , How to define two open posting period, Like only 5 and 8 posting should be open.. should not open 6 and 7..period..

1426