Maximum of the absolute values

Report a typo

Find the maximum absolute value in the array of numbers.

Try not to use the for loop, but use Stream API.

Sample Input 1:

1 4 7 -2 -5

Sample Output 1:

7

Sample Input 2:

1 4 7 -2 -8

Sample Output 2:

8
Write a program in Java 17
import java.util.Arrays;
import java.util.Scanner;

public class Main {

/**
* Returns the largest absolute value in the array of numbers.
*
* @param numbers the input array of String integer numbers
* @return the maximum integer absolute value in the array
*/
public static int maxAbsValue(String[] numbers) {
// write your code here
}

// Don't change the code below
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println(maxAbsValue(scanner.nextLine().split("\\s+")));
}
}
___

Create a free account to access the full topic