How to Swap Two Number without using any Third Variable and Arithmetic Operator
Step 1: let us open the notepad and write the following code.
Code:
- class swap {
- public static void main(String arg[]) {
- System.out.println("Before swapping");
- int a = 20;
- int b = 40;
- System.out.println("value of a:" + a);
- System.out.println("value of b:" + b);
- System.out.println("After swapping");
- a = a ^ b;
- b = a ^ b;
- a = a ^ b;
- System.out.println("value of a:" + a);
- System.out.println("value of b:" + b);
- }
- }
Step 3: Open command prompt(press window +R and write cmd and hit ok).

Step 4: Open command prompt.

Step 5: Go to "C:/kiran/program" by using cmd.

Step 6: now, write the following code for checking my java file is compile or not.
javac sp.java
output


SubashPosted Sep 19, 2016, 7:46 AM
Nice
Satabdi MohapatraPosted May 22, 2015, 6:53 AM
very nice