Do I need to initialize the max to something else? Setting it to zero doesn't work either. Don't know how to do this without making another method.
package com.codegym.task.task05.task0532;
import java.io.*;
/*
Task about algorithms
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int maximum = Integer.MIN_VALUE;
//write your code here
int n = Integer.parseInt(reader.readLine());
for (int i = 0; i < n; i++)
{
int j = Integer.parseInt(reader.readLine());
if (j > maximum && j > 0)
{
maximum = j;
}
else if (j <= 0)
{
}
}
System.out.println(maximum);
}
}