java - Create Enumeration of objects -


i need create java.util.enumeration of fruit objects can pass method during test. it's legacy code , cannot change method signature.

public void get(enumeration<fruit> fruits){} 

my fruit class:

public class fruit{     string name;     //getters , setters    } 

how can create enumeration of fruit objects?

you can use collections.enumeration(collection<t>) method convert collection, such list<fruit>, enumeration<fruit>:

list<fruit> fruits = new arraylist<>(); fruits.add(new fruit()); enumeration<fruit> fruitenumeration = collections.enumeration(fruits); 

Comments

Popular posts from this blog

c - Calling a function within a loop -

vb.net - Unbound DataGridView add row with checkbox error -

How i fill combobox items in Radgridview manually using in vb.net -