Given the task of finding the largest number. There is a file chisla.txt , containing the numbers 3, 8, 1, 5 in the column. It is necessary in the code to read this file and find the largest number.
I know how to display these numbers on the screen and how to write an array to find the largest one in it.
But how to combine these two tasks? How to write in the code this "transition" from one task to another?
import java.io.*; import java.util.*; public class X { public static void main(String[] args) { BufferedReader in = new BufferedReader(new FileReader("\\chisla.txt")); //как их связать? int[] array = {...}; int max = 0; for (int i = 0; i < array.length; i++) { if (max < array[i]) max = array[i]; } System.out.println("Max: " + max); } }
BufferedReader? - Regent