0

Does Java's ArrayList store data at runtime only?

22nd Sep 2022, 11:57 AM
Simon Ihemba
Simon Ihemba - avatar
2 Answers
+ 4
Yes. The data is lost, deleted from memory after the program finished running. Saving the data for future use, can be done separately, you can search the topics of "persistence" and "serialisation" to learn more. Data can be saved into a file or in a database for example, and next time your program can read it from the same location when starting up.
22nd Sep 2022, 12:10 PM
Tibor Santa
Tibor Santa - avatar
+ 3
As I understood, any instance of any class, including whatever data they may be carrying, will be destroyed once the program is terminated (end of run-time). The only way to achieve data persistence, was to write them into file, stored in disk or other storage media.
22nd Sep 2022, 12:12 PM
Ipang