here is the code:
import java.util.Collections;
import java.util.Scanner;
public class task2 {
public static void main(String[] args) {
int n;
Scanner numbers = new Scanner(System.in);
System.out.print("Enter the number of elements you want to store: ");
// reading the number of elements from the that we want to enter
n = numbers.nextInt();
// creates an array in the memory of length 10
int[] array = new int[10];
System.out.println("Enter the elements of the array: ");
for (int i = 0; i < n; i++) {
// reading array elements from the user
array[i] = numbers.nextInt();
}
System.out.println("Array elements are: ");
// accessing array elements using the for loop
for (int i = 0; i < n; i++) {
System.out.println(array[i]);
}
System.out.println("The max value is: " + Collections.max(numbers));
}
}
I am getting an error saying "The method max(Collection<? extends T>) in the type Collections is not applicable for the arguments (Scanner)"
If anyone could please help that would be great, please keep in mind that I am an absolute beginner in java, so please forgive me for for any silly mistakes that I've made.