Re: derived class how to
From: Ray Tayek (rtayek.no_at_spam.comcast.net)
Date: 11/30/03
- Next message: Ray Tayek: "Re: validate xml with scgema using sax gets a: "Valid documents must have a <!DOCTYPE declaration.""
- Previous message: Leonard Slatkin: "NetBeans: How to mount the Java SDK javadocs (on Mac, if that matters)"
- In reply to: f: "derived class how to"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 30 Nov 2003 07:13:27 GMT
f wrote:
> Suppose I have
>
> class Data{
> ...
> }
>
> class DData extends Data{
> ...
> }
>
> interface A {
> Data getData();
> }
>
> interface DA{
> DData getData();
> }
>
> What I want from DA is to focus on a special kind of Data, while it
> still can be used as A. But it does not compile. How can I fixed it?
>
it compiles fine, try:
class Data {}
class DData extends Data {}
interface A { Data getData(); }
interface DA { DData getData(); }
public class Main
{ public static void main(String[] args) {} }
>
> Can I do this:
>
> interface A {
> void getData(Data data);
> }
>
> interface DA{
> void getData(DData data);
> }
sure, but maybe DA should extend A and you can add the extra behaviour
there (if you really have extra behaviour).
depends on what you want to do.
hth
- Next message: Ray Tayek: "Re: validate xml with scgema using sax gets a: "Valid documents must have a <!DOCTYPE declaration.""
- Previous message: Leonard Slatkin: "NetBeans: How to mount the Java SDK javadocs (on Mac, if that matters)"
- In reply to: f: "derived class how to"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|