Online assessments feed your program data through standard input and check what you print, so reading and printing correctly is half the battle. Scanner is the simple choice for practice and most test platforms. When the input is very large, BufferedReader is much faster and avoids time-limit failures. Watch for the leftover newline after nextInt(), a classic bug that silently skips a line.