Re: Own implementation of an interface
- From: dagon@xxxxxxxxx (Mark Rafn)
- Date: Sat, 28 Oct 2006 20:02:34 -0700
gabriel <petroleum@xxxxxxxxx> wrote:
My question is, how would i go about creating my own instance of this
interface so that the API utilises my methods instead of the blank,
skeleton ones already provided?
Is it simply Public interface myInterface extends APIInterfaceCLassNAMe?
You probably want public myClass implements APIInterfaceName. And provide
actual implementations of all the methods. If you write an interface, you can
declare methods but not actually implement any of them.
or is there some other method?
As far as java goes i've always been a little hazey around the concept
of interfaces, thus my confusion.
An interface is just a pure abstract class, with a slightly different syntax
for creating the subclass - you implement it rather than extending it.
Many frameworks provide both an interface and a convenience base class that
partially implements it and lets you override just the part you want to change
(like Swing's Action interface and AbstractAction class - you can implement
Action or extend AbstractAction, depending on your needs).
I haven't played with Robocode much, but I thought it did this as well - you
extend Robot (or AdvancedRobot) and override the methods that get called at
various events.
--
Mark Rafn dagon@xxxxxxxxx <http://www.dagon.net/>
.
- Follow-Ups:
- Re: Own implementation of an interface
- From: Lew
- Re: Own implementation of an interface
- References:
- Own implementation of an interface
- From: gabriel
- Own implementation of an interface
- Prev by Date: Re: 3D & web application ?
- Next by Date: Re: Own implementation of an interface
- Previous by thread: Re: Own implementation of an interface
- Next by thread: Re: Own implementation of an interface
- Index(es):
Relevant Pages
|
|