Max value in array

class Test
{
static int arr[] = {10, 324, 45, 90, 9808};

 // Method to find maximum in arr[] 
 static int largest() 
 { 
     int i; 
       
     // Initialize maximum element 
     int max = arr[0]; 
    
     for (i = 1; i < arr.length; i++) 
         if (arr[i] > max) 
             max = arr[i]; 
    
     return max; 
 } 
   
 // Driver method 
 public static void main(String[] args)  
 { 
     System.out.println( largest()); 
    } 

}
can u say where i done mistake my code partially running

@karthik1989photos
you code seems correct send me the actual code which you submitted on Hacker block.

i submitted this code only

you are taking a static array rather you should take an array as input from the user.

can u provide the code i stuck up doing some errors

i can share how you can take input
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner scn=new Scanner(System.in);
int n=scn.nextInt();
int a[]=new int[n];
for(int i=0;i<n;i++){
a[i]=scn.nextInt();
}

}

}

now try to implement it on your own.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.