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

Need provab technical test questions

2840


hi this is uday i want prepare for nic exam if any one have previous question papers please send me or atlest guide me how to prepare my ID is udaykiran4u@in.com

1902


Any real time example of O2C process from taking order till creating invoice.

2364


what are resources in case of Threads

2283


what is the system development cycle

1833


What r the attributes using in Win Runner?

2407


suppose we have ten members of a physical file but we want the output of last 5 members only.how to achieve that?

2077


Write code to read the records from a file and load any array of size 99?make sure that you take care of all the error conditions?

2062


Write a shell program. Enter number of days from keyboard. Find out the number of years, month and days it contains

2066


what is meant by life cycle of a business

2291


Can anyone send me NIC question papers alongwith answers on nidhi1485@yahoo.co.in? Urgently needed.. Thanks in advance

2376


how to check single or double byte in struts

1983


what are the topics choosen for jam round for interviews

1657


what is difference between object oriented programming structure and object oriented programming system?

1936


how do u handle table control inbdc explain the process in steps iwant the answer in urgent please forward this even i know how to explain there

2216