Write a simple program to swap the numbers.

 Solution :- 

package mv;

public class SwapNumber {

public static void main(String[] args) {
int a=20;
int b=30;
System.out.println("Before swapping:a:"+a+",b:"+b);
int temp=a;
a=b;
b=temp;
System.out.println("After swapping: a:"+a+",b:"+b);

}

}

Comments

Popular posts from this blog

How to create React project using command prompt?

How to achieve abstraction?

Interview Question? How to find square of each element in this Array {2,4,5,6,8} using map ?