Java SE 9 is nearing its release date. At this time we have a fair idea about new features in Java 9. One of the major enhancements is the introduction of Private Methods in Interfaces. Initially, it might be confusing to understand requirement of private methods in an Interface, but let's try to understand it step by step. Pre Java 8 Era In pre Java 8 era, Interfaces were only skeletons to define class structure. They were not allowed to have definition for any method. public interface DBManager{ String USER_NAME = "xyz"; String PASSWORD = "*********"; void save(Employee obj); void save(Department obj); } This created a situation, where, if we had single behavior for a method, we had to repeat same piece of code in each implementing class. This resulted in lot of redundant code. Another solution was, to use Abstract Class instead of an Interface. This approach had its own obvious problems. Default Methods in Java
Articles on software development