• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

abstract class and method

 
mark smith
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The argument lists are different, so this should be fine. It works when I compile it. What error message are you getting?
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the design of the program it's available at:

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

any comment are welcome...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic