Hi ranchers ! Is such thing as array of interface supported in Java ?
I understand that I can create array of Object and then cast each element to my interface. I understand also that in incoming java 1.5 will be generics. (that not only make the language more complex, but (prabably) can help in the case) I understand also about array of base class, but I wish exactly array of interface, (the elements of the array can be without common base class, (only Object can help here, because it alwais base class for all)) ;-) Really I think that such thing is not implemented in Java, but... ? Thank you ! [ November 30, 2003: Message edited by: Igor Ko ] [ November 30, 2003: Message edited by: Igor Ko ] [ November 30, 2003: Message edited by: Igor Ko ]
In Java, you can define an array of any type. As interfaces are types, you can indeed define arrays of interfaces -- i.e., Cloneable c = new Cloneable; declares and constructs an array that can hold ten objects that implement the "Cloneable" interface.