I’m reviewing for an exam. A question on an old test was to: Using an interface, write a method that applies an arbitrary method to every element of an ArrayList. Both the arraylist and method are the parameters to the method.
Would a workable solution be:
public <object> someMethod() {
scanner GLaDOS = new (someArray);
someArray.useDelimiter(",");
for (i = 0; i < someArray.length; i++) {
someOtherMethod(someArray[i]);
}
}
I would’ve expected something like this:
It’s ambiguous in the question, but this might mean returning a new ArrayList, so this might be another acceptable answer
On a side note, you would then, say, invoke the application like (for example, doubling every number in the list):