0

What is the use of this private nested interface?

Below code is for reference:

class a {
    private static interface Ione {
        void mone();
    }
}
assylias
  • 321,522
  • 82
  • 660
  • 783
arjun
  • 57
  • 2
  • 6
  • 1
    So nested private classes can implement it – SLaks Aug 27 '13 at 16:33
  • look into So question http://stackoverflow.com/questions/71625/why-would-a-static-inner-interface-be-used-in-java – Prabhaker A Aug 27 '13 at 16:36
  • 1
    There's a good answer at http://stackoverflow.com/questions/17971554/private-interfaces/17971629#17971629, though the question itself was closed for poor clarity. – Andy Thomas Aug 27 '13 at 16:38
  • prabhaker my question is about private interface not public interface. – arjun Aug 27 '13 at 16:39
  • @andy thomas do you think it is answered? why it is closed without proper explanation. – arjun Aug 27 '13 at 16:48
  • 1
    @user2489380 The question was not very clear originally (which is why it got closed) - I have reworded it. The answer gives a good example. – assylias Aug 27 '13 at 16:49

1 Answers1

-1

You do this when the function of the method only relates to the containing class and even then its not really something you have to do. This would be one of those coding preference things. So as an example you would have other classes that want to implement Ione and you would want those other classes to know that Ione is related to class a.

public class SomeOtherClass implements a.Ione {
 ...
}
spartikus
  • 2,852
  • 4
  • 33
  • 38