java - Private Interfaces -
how can use methods of private interface in our code?
abstract classes cannot instantiated. so, if need use methods of abstract class, can inherit them , use methods.
but, when talk interfaces, need implement them use methods.
the private keyword means "anyone in same class":
public class foo { private interface x {...} private class x1 implements x {...} } this means classes declared inside of foo can use interface foo.x.
a common use case command pattern foo accepts, say, strings , converts them internal command objects implement same interface.
if add second class bar file foo.java, can't see foo.x.
Comments
Post a Comment