java - How to Create Object of Interface? -


i have field interface

how create object of interface?

look under known implementing classes: customfield

this class looking for

field<t> myfield = new customfield<t>(string name, datatype<t> type); 

for list (array) of fields:

arraylist<field<t>> arr = new arraylist<field<t>>(); arr.add(myfield); 

if you're not familiar generics, t represents reference type (class) want use

for simple array type (not arraylist) be:

field<t>[] arr = new field<t>()[size]; arr[0] = myfield; 

consider using arraylist or other collection, there no reason use plain old array references variables in case.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -