Max value in array

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int size = Integer.parseInt(sc.next());
int max=0;
int arr[] = new int[size];
for(int i =0;i<size;i++) {
arr[i] = Integer.parseInt(sc.next());
if(max<arr[i])
max =arr[i];

	}
	System.out.println(max);
}

}

1 test case is not passed

Hello @Pranav_Chaudhary,

You are required to ask doubts related to C++.
As this is a C++ course, so i am not allowed to respond to your java code.

it is not mentioned anywhere that doubts must be only in c++

If I am not wrong then your course is (Algo++)Advanced Data Structures in C++.
Am I correct?

I can answer your doubt, but I am a TA of C++ course.
In your code, you are not considering for the case when there are all negative numbers in the array.
The output will be 0 of your code, which is wrong.
Solution:
int max=Integer.MIN_VALUE;

Hope, this would help.
Give a like, if you are satisfied.