Hello, community!
I've been working on a small app with a very simple algorithm. Said app must create 50 different objects with randomly generated atributtes (name, id and phone number must be random for each one of them) and store them in a Collection (ArrayList) which must be place in a .dat archive. A second app must retrieve the List and print it via console.
First part seems to be well implemented, for each individual object can be printed. Override of the Object toString() is as follows:
The problem begins when trying to print the list, for the console prints only:
// [Adrian 9109720 - Q] Whitneyener // when the print of the whole list is called via the System.out.println(list) or System.out.println(in.readObject()) command.
Thanks in advance, for any small help is much appreciated!!
public static void main(String[] args) throws FileNotFoundException, IOException, ClassNotFoundException { String name = "", id = ""; int phone; ArrayList<Aspirante> list = new ArrayList<>(); for (int i = 0; i < 50; ++i) { name = nameRandom(); id = Integer.toString((int) (Math.random() * 10000000)) + " - " + capitalRandomChar(); phone = (int) (Math.random() * 10000000); list.add(new Aspirante(name, id, phone, i)); } try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("lib\\list.dat"))) { out.writeObject(list); out.close(); } try (ObjectInputStream in = new ObjectInputStream(new FileInputStream("lib\\list.dat"))) { System.out.println(in.readObject()); in.close(); } }