I need to develop interface which can be implemented only once. If other class try to implement same interface in same project then it should not be allowed or give an error.
interface A {
void someMethod();
}
class B implements A {
void someMethod() {
// implementation here
}
}
Now I want to restrict other classes to implement interface A
class c implements A { //this should not allowed in this project
}
Is it possible to develop this kind of interface? Can anyone suggest, how can I go through to achieve this?
Put your
interface Awithclass Bin same package.All the classes which should not implement
A, should be outside this package.