← all problems

Rotate three values 🌶️🌶️🌶️

The int variables first, second and third have starting values, and the three locked lines at the bottom print first, then second, then third. Write code in the box that rotates the values: after your statements run, first should hold what second started with, second should hold what third started with, and third should hold what first started with. Your code will be tested with several different starting values.

Main.java — the program frame below is already written; you're only completing the code in the editable box. Your code will be run several times, each with different starting values for the variables at the top.

public class Main {
    public static void main(String[] args) {
        int first = 1;
        int second = 2;
        int third = 3;
        // ---- write your code below ----
        System.out.println(first);
        System.out.println(second);
        System.out.println(third);
    }
}