i m getting 0 if i try
3
-1
-3
-2
i know its because maximum is initialized as int maximum = 0;
but how to resolve it?
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 count = 0, num;
int maximum =0 ;
String s = reader.readLine();
int N = Integer.parseInt(s);
while(count<N)
{
num = Integer.parseInt(reader.readLine());
if( num > maximum){
maximum = num;
}
count++;
}
System.out.println(maximum);
}
}