so I'm writing a registration system app for a university (writing it in JAVA) I have three classes Student, Faculty and Course. In the driver class, I have three ArrayLists of each type to hold different objects of said types. I need an option to print out the current elements in the list and as it is now I basically have the same code written three times for each type of list. I was wondering how would I would implement a function to do this for all three lists. My main question is how would I set up the parameters of the function so that it could print out any type of ArrayList.
One possible solution that I thought of was to make the ArrayLists static and just have the function take in an int as parameter to indicate what type of list is being displayed. I'm not sure if it would be a good idea to make the lists static though.
or am I just overthinking this and I should just leave it as is. my main method is getting pretty long though so I was trying to figure out how to simplify with other methods.