Find the error

Report a typo

Your friends asked for your help in solving a coding problem. They were trying to create a utility method for swapping two integer numbers, but something went wrong and the method does not work as expected. Use your debugging skills to fix the problem.

Sample Input 1:

29
-16

Sample Output 1:

-16
29
Write a program in Java 17
import java.util.Scanner;

class Util {
public static int[] swapInts(int[] ints) {
return new int[]{ints[1], ints[0]};
}
}

class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

int[] ints = new int[2];
ints[0] = Integer.parseInt(scanner.nextLine());
ints[1] = Integer.parseInt(scanner.nextLine());

Util.swapInts(ints);

System.out.println(ints[0]);
System.out.println(ints[1]);
}
}
___

Create a free account to access the full topic