How to swap two String values without using a
third variable?
Answer Posted / bharat
import java.util.Scanner;
public class Swap {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int a, b;
System.out.println("Enter a and b");
Scanner in = new Scanner(System.in);
a = in.nextInt();
b = in.nextInt();
System.out.println("Befor Swapinng :" + "a : " + a + "\t" + "b :" + b);
b = a + b;
a = b - a;
b = b - a;
System.out.println("a : " + a + "\t" + "b :" + b);
}
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
in cobol,wat is the difference in using 'set index in occurs clause' ....and 'occurs depending-on clause'
< DL Compact > tag is used for
5. How do you round the addition or subtraction of two numbers in assembler?
How to call dll API sub routine in VB Form.
Difference of Console, web & windows applications?
Explain with examples any 2 features of OOPS.
WHAT IS THE MEANING OF CONSTANT ...EXEEDS LENGTH LIMIT WHILE COPYING FROM PS FILE TO KSDS
What is the use of Differ interface check box in Ship confirm?
how do i add a column dynamically in a table by using java application?
how do i create my own exception class which will restrict IO exception?
what is programmable BIST in today ic design
What is SOLID Principle in Programming Language?
differences between qtp10.0 and 11.0 ?
Explain three modes in which files can be accessed from python program
What is ur porject Architecture? If anyone ask what i have to specify here..