Java question

Osphisa

Neophyte
Joined
Mar 5, 2019
Messages
2
I'm not a java person so this may have a simple answer, but I just don't know it.

I have an object that has multiple elements of the same naming format i.e. element0, element1, element2, etc

Right now, I am adding them to a an ArrayList in the following manner:

Code:
list.add(element0);
list.add(element1);
...
So on and so forth.

They are all of the same type but there are other elements that are also of the same type but not of the same naming convention (plus, I won't really be using them in the same manner). Is there any way to add these elements to the list in a looping manner? Something like:

Code:
for(int X=0; i<SIZE; X++)
list.add(elementX);
I know how to get cute and do this type of thing in C-based languages but not in java. As it is, it looks really hacky and messy and I'd like to clean it up if at all possible.
 
Top