Swapping Two Numbers in Java

class Swapper
{
    int a=23, b=32, temp;
    void before()
    {   
        System.out.println("The values of a and b Before swapping are");
        System.out.println("A="+a+"B="+b);
    }

    void swapping()
    {
        temp=a;
        a=b;
        b=temp;
    }
   
    void after()
    {
        System.out.println("The values of a and b After swapping are");
        System.out.println("A="+a+"B="+b);
    }
}

class Swapp
{
    public static void main(String [] arg)
    {
        Swapper s1= new Swapper();
        s1.before();
        s1.swapping();
        s1.after();
    }
}

Popular posts from this blog

AGRICULTURAL SCIENTIST RECRUITMENT BOARD

CIVIL SERVICES' (I.A.S.) EXAMINATION

HSC Exam Time Table 2013 Arts, Commerce, Science