java - Detect type of object in ArrayList -
I am trying to create a class that will change the Arrayialists of objects into ArrayLists of other objects. I.e.
Arreelist & lt; Foo & gt; Convert (Arreelist & lt; times> Input) {// Conversion Argument} ArrayList & lt; Bars & gt; Convert (Arreelist & lt; Foo & gt; Input) {// Conversion Argument}
Unfortunately Java does not want to do two functions with the same name and it has the same input and output Believe in
I am trying to go to a different route. Instead of many tasks with the same name, I want to create a function that accepts an ArrayList, determines what type of object is inside, makes appropriate conversions, and gives an ArrayList:
ArrayList Convert
Is such a thing possible? About
how about an interface:
public class converter & Lt; From, to & gt; {List & lt; To & gt; Convert (list & gt; input & gt; input); }
and after that you want as many implementations for example:
Personal Static Ultimate Converter & lt; Foo, Bar & gt; FooToBarConverter = New Converter & lt; Foo, Bar & gt; () {Public listing & lt; Bars & gt; Convert (list & lt; Foo & gt; input) {...}}
Comments
Post a Comment