DEV Community

Arshad Ali
Arshad Ali

Posted on

JAVA- Swap two Variable


public class Main {

    public static void main(String[] args) {


        String x = "Water";
        String y = "Kool-Aid";
        String temp;

        temp = x;
        x=y;
        y=temp;

        System.out.println("x: "+x);
        System.out.println("y: "+y);


    }


}



Enter fullscreen mode Exit fullscreen mode

Top comments (0)