package Exercise30_StoringRecords;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Scanner;
public class StoringRecords {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Filename:");
String file = scan.nextLine();
ArrayList<Person> records = readRecordsFromFile(file);
System.out.println("Persons: " + records.size());
System.out.println("Persons:");
for (Person person : records) {
System.out.println(person);
}
}
public static ArrayList<Person> readRecordsFromFile(String file) {
ArrayList<Person> persons = new ArrayList<>();
try (Scanner scanner = new Scanner(Paths.get("data3.txt"))) {
while (scanner.hasNextLine()) {
Scanner line = scanner.nextLine();
String[] parts = line.split(",");
String name = parts[0];
int age = Integer.valueOf(parts[1]);
}
}
return persons;
}
}
so I have to read a file and seperate the file and then like print it, why is the split for me red? is it because of the return? (the return was already there)