d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > What's Happening Here...
Add Reply New Topic New Poll
Member
Posts: 31,390
Joined: Mar 25 2009
Gold: 99.00
Mar 4 2019 09:57pm
Code
ISaveable werewolf = new Monster

^What is happening here, it's creating an object of interface and monster class, not sure what this means.
/EDIT To be clear, ISaveable is an interface.

Code
List<String> values = new ArrayList<String>();

and again here, using List and ArrayList.. not sure what's happening. Thanks

This post was edited by ferf on Mar 4 2019 09:58pm
Member
Posts: 12,703
Joined: May 17 2013
Gold: 2,935.00
Mar 5 2019 12:23pm
Assuming that Monster implements ISaveable, and we already know that ArrayList implements the List interface.
All methods defined in those interfaces are available on objects of the type Monster or ArrayList, since they implement it, which is why you can do that.

This post was edited by Klexmoo on Mar 5 2019 12:24pm
Member
Posts: 31,390
Joined: Mar 25 2009
Gold: 99.00
Mar 8 2019 06:14pm
Quote (Klexmoo @ Mar 5 2019 02:23pm)
Assuming that Monster implements ISaveable, and we already know that ArrayList implements the List interface.
All methods defined in those interfaces are available on objects of the type Monster or ArrayList, since they implement it, which is why you can do that.


Thanks!!
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll