Swap Two Numbers in Java.
Swap Two Numbers in Java.
EXAMPLE :-
public class swap {
public static void main(String[] args) {
int fst = 8, sec = 2;
System.out.println("Before Swaping...");
System.out.println("First Number => " + fst);
System.out.println("Second Number => " + sec);
int temp = fst;
fst = sec;
sec = temp;
System.out.println("After Swaping...");
System.out.println("First Number => " + fst);
System.out.println("Second Number => " + sec);
}
}
OUTPUT
Before Swaping...
First Number => 8
Second Number => 2
After Swaping...
First Number => 2
Second Number => 8
No comments:
Post a Comment
Please do not any spam link in Comment Box