The two methods serve very different purposes. Collections only exist at runtime, making them fast to access, but are gone as soon as the JVM exits.
Databases persist whatever you store in them so that the data is still there the next time you start up your program. But they are much slower to access than anything that's in memory.
Does this answer your question?
bacon. tiny ad:
a bit of art, as a gift, the permaculture playing cards