Java program to swap the given numbers using only two variables
KW.java
Output
kodingwindow@kw:~$ javac KW.java
kodingwindow@kw:~$ java KW ——————————————————————————————————————————— Program to swap the given numbers ——————————————————————————————————————————— a = 10 b = -0.25 —————————————————————————— After swapping... —————————————————————————— a = -0.25 b = 10.0 ——————————————————————————————————————————— kodingwindow@kw:~$
Java program to swap the given numbers using three variables
KW.java
Output
kodingwindow@kw:~$ javac KW.java
kodingwindow@kw:~$ java KW ——————————————————————————————————————————— Program to swap the given numbers ——————————————————————————————————————————— a = 25 b = -3.1428 —————————————————————————— After swapping... —————————————————————————— a = -3.1428 b = 25.0 ——————————————————————————————————————————— kodingwindow@kw:~$
What Next?
Java Control Statements
Advertisement