Q:

Java Program to swap two numbers using temporary variable

0

Java Program to swap two numbers using temporary variable.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import java.util.*;
import java.lang.*;
import java.io.*;

public class SwapNumbers
{
        public static void main(String[] args)
             int first = 4, second = 5;
             System.out.println("--Before swap--");
             System.out.println("First number = " + first);
             System.out.println("Second number = " + second);
                int temp = first;
                first = second;
                second = temp;
             System.out.println("--After swap--");
             System.out.println("First number = " + first);
             System.out.println("Second number = " + second);
    }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now