public class Main { public static void main(String[] args) { int A = 5; int B = 10; System.out.println("До замены:"); System.out.println("A = " + A); System.out.println("B = " + B); int temp = A; A = B; B = temp; System.out.println("После замены:"); System.out.println("A = " + A); System.out.println("B = " + B); } }
Вывод:
До замены: A = 5 B = 10 После замены: A = 10 B = 5
public static void main(String[] args) {
int A = 5;
int B = 10;
System.out.println("До замены:");
System.out.println("A = " + A);
System.out.println("B = " + B);
int temp = A;
A = B;
B = temp;
System.out.println("После замены:");
System.out.println("A = " + A);
System.out.println("B = " + B);
}
}
Вывод:
До замены:A = 5
B = 10
После замены:
A = 10
B = 5