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

hi..this is kartheek..complted mca in 2009..but i dont have knowledge in programing..but to learn new language.. which one is suitable for me?is SAP or IBM mainframes is suitable for me..?if it suits how much will it costs..?pls answer...

2046


if 3 duplicate records, by keeping one original and one duplicate record, and how to delete remaining 2 duplicates in sql server 2008

2208


Difference between debugging, running, executing of an application

4091


what is technical system, business system, logical system in sap pi7.0

2633


what is the diff bw sql direct and jdbc update can't we do select and updating operation in sql direct

2213


what is apt_dump_score in datastage where it is useful

2005


Colors specified with the notation

2300


What is ur porject Architecture? If anyone ask what i have to specify here..

2010


Hello Experts, What is the difference between move and move corresponding exactly? please post me asap

1926


how will you code the subfile which is in editing mode (multiple case subfile)?

2160


in teradata level primary in table level allows duplicates why?

2144


Write a program to swap the content of two variables without using a third variable.

1116


< No Frames > tag is used for

2829


Please describe an example where you used object orientation in one of your programs.

2017


Hi I am Rathnam, How To Remove the duplicates with out using remove duplicate stage in the datastage

1990