LinkedList : Collections.max() throwing NoSuchElementException
I am not iterating the LinkedList by any means like scanner or other methods, I am using Collections.max() to get maximum number from the LinkedList . I have read on Stack Overflow that this exception is thrown due to iterator or scanner or tokenizer, but I am using none of them. import java.io.*; import java.util.*; class TLG { public static void main(String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); LinkedList<Integer> first = new LinkedList<Integer>(); LinkedList<Integer> second = new LinkedList<Integer>(); int cases = Integer