For Programmers: Free Programming Magazines  


Home > Archive > Java Help > June 2005 > 2 extends









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author 2 extends
Irlan agous

2005-06-09, 8:58 pm

Hello i want to extend from 2 classes lik

public class PatientImpl extends DataModel ,UnicastRemoteObject implements
PatientInterface throws RemoteExeption;

But this gives an error message, dfoes anyone knows how to solve this?

Thanks


Andrew Thompson

2005-06-09, 8:58 pm

On Thu, 9 Jun 2005 13:38:40 +0200, Irlan agous wrote:

> Hello i want to extend from 2 classes ...

...
> But this gives an error message, dfoes anyone knows how to solve this?


Try reading the group, rather than simply posting questions to it.
Here is a link to one of the answers given for the very previous
message thread to this group!
<http://groups.google.com.au/group/c...ee4b041ae?hl=en>

--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
Bryce

2005-06-09, 8:58 pm

On Thu, 9 Jun 2005 13:38:40 +0200, "Irlan agous" <irlan345@msn.com>
wrote:

>Hello i want to extend from 2 classes lik
>
>public class PatientImpl extends DataModel ,UnicastRemoteObject implements
>PatientInterface throws RemoteExeption;
>
>But this gives an error message, dfoes anyone knows how to solve this?


No multiple inheritence in Java.

--
now with more cowbell
Thomas G. Marshall

2005-06-10, 8:58 pm

Bryce coughed up:
> On Thu, 9 Jun 2005 13:38:40 +0200, "Irlan agous" <irlan345@msn.com>
> wrote:
>
>
> No multiple inheritence in Java.


{cough, cough}....except for interfaces.


--
Everythinginlifeisrealative. Apingpongballseemssmalluntilsomeoneramsi
tupyournose.


Hal Rosser

2005-06-11, 3:58 am

Pehaps you may consider creating an instance variable of the 'other' class.
This approach is preferred in many cases. Composition is a good alternative
to multiple inheritance, and is preferred by some authors of the subject.
HTH

"Irlan agous" <irlan345@msn.com> wrote in message
news:6bebb$42a82a41$52ade8f3$30956@news.versatel.nl...
> Hello i want to extend from 2 classes lik
>
> public class PatientImpl extends DataModel ,UnicastRemoteObject implements
> PatientInterface throws RemoteExeption;
>
> But this gives an error message, dfoes anyone knows how to solve this?
>
> Thanks
>
>



Tor Iver Wilhelmsen

2005-06-11, 3:58 am

"Thomas G. Marshall" < tgm2tothe10thpower@replacetextwithnumber
.hotmail.com> writes:

> {cough, cough}....except for interfaces.


Or through inner classes and using methods instead of casting.

public class MyClass {

private MyOtherType myOtherTypePart = new MyOtherType() {
public void overriddenMethod() {
// Should access members of MyClass
// otherwise it's pointless
}
}

public MyOtherType asMyOtherType() {
return myOtherTypePart;
}

}
The Wogster

2005-06-11, 3:58 pm

Irlan agous wrote:
> Hello i want to extend from 2 classes lik
>
> public class PatientImpl extends DataModel ,UnicastRemoteObject implements
> PatientInterface throws RemoteExeption;
>
> But this gives an error message, dfoes anyone knows how to solve this?
>


There are a few tricks, an Interface is one, an instance of the second
class is another, you could potentially combine both or create a new
class that Interfaces to both, as a child of neither.

However needing multiple inheritance usually means that something in the
initial class design is broken. Often it's from trying to create a
jack-of-all-classes combining a bunch of what should be unrelated stuff
into a single class.

It's like the goto, it's legal in C, but the only times I have seen it
used, were because someone had programmed themselves into a corner.
Once I rewrote a few lines and got rid of it, the other is still there
AFAIK, because the code was so fragile, nobody was stupid enough to want
to monkey with it, even the lead programmer would not touch it.

W



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com