Hello everyone,
supposing that i have a class called “Student” that contain multiple fields (name,age,section, marks)
and i have an ArrayList of students called list , so every case of the list will contain a student, which mean i can do something like this for example :
System.out.println(list.get(0).name);
this will print the name of the student in the case 0
what i can’t do is,
how can i write that list into a text file ?
i thought about converting each field of the list into a string then write it into the file, but if i do that i will find a little trouble while retrieving the list, cause i need that every case of the list be a “Student” so i can use it in other things,
i thought about a solution like writing a star (*) before writing the list, then convert each field to string,then write another star and then when i want to retrieve depending on the line after the 1st star i will cast that element to each original type
but i don’t think am the only one who needed to write a whole type into a file so i think it must be a better solution for this
thank you