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

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -