Reputation: 5190
I have an
public interface DoIt {
void dosomething (int i, double x);
int dosomethingelse (String s);
}
some class that implement it is class_of_a
etc...
and i want to add an new method in the interface lets say diditwork(int x);
How am i suppose to do that while avoiding the problems of recompiling or whatever problem that might be ? What would be the new hierarchy ?
Upvotes: 3
Views: 138
Reputation: 2112
create another interface and let the given class implement both interfaces
e.g.
public interface DoIt {
void dosomething(int i, double x);
int dosomethingelse(String s);
}
and new interface
public interface CheckIt {
boolean diditwork(int x);
}
classes without necessity to check would implement only DoIt interface, classes with necessity to check would implement also CheckIt interface
Upvotes: -1
Reputation: 20112
you can extend your existing Interface like this:
interface DoItMore extends DoIt { diditwork(int x); }
so you will have your old interface for low level Classes and your new Interface for high level. Then you have to change the used Interface in your High level class.
Upvotes: 2
Reputation: 117587
Create a new interface and extend the old interface, something like:
interface DoIt2 extends DoIt
{
// void doSomething(int i, double x);
// int doSomethingelse(String s);
void didItWork(int x);
}
Upvotes: 7