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
Post a Comment