Use java.beans.XMLEncoder and pass it the ArrayList. It will encode the entire ArrayList and it's constituent classes and their ArrayLists of other classes and primitives all the way down.
Your custom classes just need to comply with JavaBeans standards (get/set/add methods, a no-args constructor).
It encodes to a Stream so you can do multiple encodes and subsequent decodes on the same stream/file.
I have a little demo using an ArrayList of instances of a class that contains another ArrayList among its instance variables, should you need convincing...
That's the solution I proposed earlier, except that he misses a key point - which is that ArrayLists can also be encoded/decoded (the ArryaList class has been retrofitted with extra methods to support XML encoding). He messes about writing the arraylist elements one at a time, then reading them back in and addig them to a new list. All you need is to encode the ArrayList itself (one call) and decode it (one call)
Help! I want to create a java program that finds the highest even integer among the values entered by the user. Stop asking values when a value less than 1 have been entered. If no even integer is entered, display "No Even Integer"
Hi, as I was told that my code doesn’t scale well at all, I thought perhaps I’d try to get a better understanding of interfaces/abstract classes and classes and the relationship between them.
I don’t want at this stage work on a big separate project as I've already got plenty ...