@fred Вы можете возвращать массив значений из метода.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
class Main { public static int[] get_summ_and_diff(int x, int y){ int summ = x + y; int diff = x - y; return new int[]{summ, diff}; } public static void main(String[] args) throws Exception { int[] diff_and_summ = get_summ_and_diff(10, 5); System.out.println(diff_and_summ[0]); System.out.println(diff_and_summ[1]); // Вывод : // 15 // 5 } } |