File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes abstract class and method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "abstract class and method" Watch "abstract class and method" New topic
Author

abstract class and method

mark smith
Ranch Hand

Joined: Apr 05, 2005
Posts: 250
hi

i have an abstract class with an abstract method



i tried to had



we can't have some abstract method with the same name... java don't like that...

are there a way to do that?

thanks
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

The argument lists are different, so this should be fine. It works when I compile it. What error message are you getting?


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
Originally posted by marc weber:
The argument lists are different, so this should be fine. It works when I compile it. What error message are you getting?


Must not be adding to what he already has then. In total he has:

The first two are identical because Socket is a subtype of Object.

You could change the order of the parameters. You could use Object rather than Socket and simply check for a Socket via instanceof to delegate the functionality depending on type. You could remove the first two methods and have the third allow null for either the Socket or the Object and depending on which is null do what you would have done in the others. This kind of problem arising usually indicates a larger flaw in the design to me.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Ken Blair:
... The first two are identical because Socket is a subtype of Object...

One is "more specific" than the other, but they are not identical. This compiles fine for me with all three abstract methods in the same class. If you're getting an error, what error are you getting?
Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
I was wrong. I don't get an error actually, I was just thinking you couldn't do it, at the time I hadn't even tried.
mark smith
Ranch Hand

Joined: Apr 05, 2005
Posts: 250
the design of the program it's available at:

http://www.laboiteaprog.com/architecture.pdf

any comment are welcome...
 
 
subject: abstract class and method