I take the chance to ask someone to explain me buffer reader vs Scanner. I can use clearly Scanner but in this case is not working. Have i have to use buffer reader?
May i have to add a try catch block? (I didn't study jet i am really new in java) i will figure out how to do it.
Thanks who has the patience to experience that
package com.codegym.task.task05.task0532;
//import java.io.*;
import java.util.*;
/*
Task about algorithms
*/
public class Solution {
public static void main(String[] args) throws Exception {
//BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
// int maximum = ;
Scanner s = new Scanner(System.in);
//write your code here
int nTimes = s.nextInt();
//int array []= new int[];
ArrayList<Integer> str = new ArrayList<Integer>();
for(int i = 0 ; i <= nTimes; i++){
int num = s.nextInt();
//array [i] = num;
//add num in array
str.add(num);
}
//Collection.sort(str);
Collections.sort(str);
int max = str.get(str.size()-1);
System.out.println(max);
}
}