In order to complete one of my Java assignments, I have to do what seems like the impossible.
I have to create a method that takes in different stuff and plugs it into an array. We don't necessarily know what is being put into the array and thus the array must be able to accept String
s, Double
, Integer
, etc...
Of course, the obvious solution would be to use ArrayList<E>
(i.e. a generic array). However, that's partly the complication of the problem. We cannot use an ArrayList
, only a regular array. As far as I can find, when creating an array its intake value must be declared. Which leads me to believe that this assignment is impossible (yet I doubt the teacher would give me an impossible assignment).
Any suggestions?