I have an interface and 2 classes that implement this interface. See the code below as example.
addAchievedMilestone is a method that needs to be implemented in every class, but can only be executed by a class in the same package.
Why can't the method addAchievedMilestone be protected?
I want it to be protected so it can only be used by classes in the same package. (The method won't be extended by any other class)
But the modifier in the Project-class always needs to be public, how can I solve this?
Example code:
package Base;
public interface MilestoneAchievable {
public Milestone getMaxMilestone();
void addAchievedMilestone(Milestone m) throws Exception;
}
Project class :
package Base;
public class Project implements MilestoneAchievable{
public Milestone getMaxMilestone() {
//implementation goes here
}
public void addAchievedMilestone(Milestone m) throws Exception
{
//implementation goes here
}
}