+ 1
How to find the max value of an array? Help pls...
elements of array should be entered at runtime
4 Answers
+ 6
import java.util.Scanner;
import java.util.Collections;
import java.util.Arrays;
public class Program{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("How Many Numbers?");
int l = sc.nextInt();
Integer arr[] = new Integer[l];
for(int i=0; i<l; i++)
arr[i] = sc.nextInt();
int min = Collections.min(Arrays.asList(arr));
int max = Collections.max(Arrays.asList(arr));
System.out.println("Max: " + max +"\nMin: " + min);
}
}
+ 1
bro values should be entered by user at runtime.
+ 1
thank u bro