• Post Reply Bookmark Topic Watch Topic
  • New Topic

Specifying method signature for constructor in an interface  RSS feed

 
Pho Tek
Ranch Hand
Posts: 782
Chrome Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it a good move to specify the constructor in an interface ?

Pros vs cons ?
 
Pho Tek
Ranch Hand
Posts: 782
Chrome Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I apologize but this is one stupid question, since an interface cannot share the same name as a implementation class. Ignore.
 
Tony Morris
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The compiler will not permit it.
However, I have seen many people attempt to do it.
What they really want is an accessor method on the interface.
In your example, you want:

 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tony, can you explain?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!