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
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...
if 3 duplicate records, by keeping one original and one duplicate record, and how to delete remaining 2 duplicates in sql server 2008
Difference between debugging, running, executing of an application
what is technical system, business system, logical system in sap pi7.0
what is the diff bw sql direct and jdbc update can't we do select and updating operation in sql direct
what is apt_dump_score in datastage where it is useful
Colors specified with the notation
What is ur porject Architecture? If anyone ask what i have to specify here..
Hello Experts, What is the difference between move and move corresponding exactly? please post me asap
how will you code the subfile which is in editing mode (multiple case subfile)?
in teradata level primary in table level allows duplicates why?
Write a program to swap the content of two variables without using a third variable.
< No Frames > tag is used for
Please describe an example where you used object orientation in one of your programs.
Hi I am Rathnam, How To Remove the duplicates with out using remove duplicate stage in the datastage