Hebert Coelho wrote:You do not need to create the list every time
Doesn't that kind of depend on what is really needed? Maybe the OP really needs 10 arrayLists.
nissan Ca,
tell us what you really are trying to do. Do you need to have ten (or whatever) lists of integers, or can you use one list and clear/reset it every time?
nissan Ca wrote:my desired output should be 10 different arraylists, example, list1,list2,list3,...,list10
I'm not sure if this is what you are trying to do, but you cannot dynamically name variables. You would either need to explicitly declare all of your list1, list2, etc, but then you don't know how many you will need, so that's probably not idea.
If you need to keep/maintain many lists, you need a collection of lists. For example, if you were keeping track of lottery ticket, you'd need a list of ticket, and each ticket would have a list of integers picked for that ticket.
You would reference the collection of tickets, and then either iterate through it to see each one, or use various methods to access a specific element.
It's difficult to guide you without knowing exactly what you are trying to accomplish.