/
EugenyCh7
/
JavaAndScalaLessons
Обзор
Документация
Войти
/
EugenyCh7
/
JavaAndScalaLessons
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
JavaTest/src/ch2/ex4/Main.java
28 строк
924 B
Eugeny Chekmarev
IDEA update
15 июн 2021, 21:11
15 июн 2021, 21:11
47fadf9
Код
Авторство
О чём код?
package ch2.ex4; public class Main { public static void main(String[] args) { Box<Integer> x = new Box<>(100); Box<Integer> y = new Box<>(300); Box<Integer> z = new Box<>(100); System.out.printf("x = %s\n", x); System.out.printf("y = %s\n", y); System.out.printf("z = %s\n", z); System.out.printf("x.equals(y) = %s\n", x.equals(y)); System.out.printf("x.equals(z) = %s\n", x.equals(z)); System.out.println("swap x and y"); swap(x, y); System.out.printf("x = %s\n", x); System.out.printf("y = %s\n", y); System.out.printf("z = %s\n", z); x.value = x.value + y.value; System.out.println("x.value = x.value + y.value"); System.out.printf("x = %s\n", x); } public static <T> void swap(Box<T> a, Box<T> b) { T t = a.value; a.value = b.value; b.value = t; } }