Hi CK, The highlited line means that you must to downcast the generic Object type to MyEventListenerInterface, than the compiler alows you to call MyEventListenerInterface methods.
Regards, Adrian 2009/4/16 CK <[email protected]> > Hi Pratricio, > Thanks very much for your help! > For that one can I say that the method signature accept any obj from class > that implements > the specified interface (for this one is MyEventListenerInterface) ? > > I still have a further query about the method in MyEventSource class as > code below. > For the highlighted line, does it mean we initiate object of > MyEventListenerInterface > ??? > Can we have an obj of interface ??? > this also makes me confused? or I just short of programming knowledge? > > public void triggerSomethingEvent(String eventName){ > > // Invoke event listener > for (Object item: a1){ > MyEventListenerInterface m1 = (MyEventListenerInterface)item; > m1.somethingHappened(new MyEvent(this, eventName)); > } > } > > Thanks so much in advance, > CK > > 2009/4/16 Patricio Martínez León <[email protected]> > >> Don't worry >> >> It's because your MyEventListenerImpl implements the interface >> MyEventListenerInterface. So you can say your MyEventListenerImpl is a >> sort >> of MyEventListenerInterface. >> >> I hope this helped. Please let me know if you need more explanation. >> >> Best regards >> >> >> -----Mensaje original----- >> De: [email protected] >> [mailto:[email protected]] En nombre de CK >> Enviado el: miércoles, 15 de abril de 2009 8:15 >> Para: Free Java Programming Online Training Course By Sang Shin >> Asunto: [java programming] lab1021 - JavaBeans: exercise 4.2 >> >> >> Hi Class, >> >> Sorry for my lack behind post. >> I just have a short question as per my Subject. >> >> In MyEventSource.java, it takes Interface as variable. this make me >> confused. >> ... >> public void addMyEventListener(MyEventListenerInterface l) { >> a1.add(l); >> } >> >> Also, MyEventExample passes MyEventListenerImpl instead. >> ... >> s1.addMyEventListener( new MyEventListenerImpl() ); >> >> I know it runs successfully but I'm just not clear with it. >> If there're any post already discuss on this thing, I'm sorry but I >> can't find it. >> >> Any suggestion would be appreciate, >> CK >> >> >> >> __________ Information from ESET Smart Security, version of virus >> signature >> database 4010 (20090415) __________ >> >> The message was checked by ESET Smart Security. >> >> http://www.eset.com >> >> >> >> >> __________ Information from ESET Smart Security, version of virus >> signature >> database 4010 (20090415) __________ >> >> The message was checked by ESET Smart Security. >> >> http://www.eset.com >> >> >> >> __________ Information from ESET Smart Security, version of virus >> signature >> database 4010 (20090415) __________ >> >> The message was checked by ESET Smart Security. >> >> http://www.eset.com >> >> >> > > > > --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en -~----------~----~----~----~------~----~------~--~---
