- public class SwapTwoNumberWithThirdVariable {
- public static void main(String[] args) {
- int a = 10;
- int b = 20;
- int temp;
- temp = a;
- a = b;
- b = temp;
- System.out.println("after swap value of a: " + a);
- System.out.println("after swap value of b: " + b);
- }
- }
Output:
after swap value of a: 20
after swap value of b: 10
No comments:
Post a Comment