I want this interface to be accessible in sub-packages only(say test.sub ), not outside package-test
Making this inteface public make it visible in sub-packages but it also make it visible in other packages.
Is it possible to do this ??
if yes then how can achieve it ??
Java doesn't really have the notion of "subpackages", at least not at the language level (some of the security mechanisms could be said to work in terms of subpackages.) There's no way to do what you're asking.
If you explain what you actually want to accomplish, maybe we could offer some suggestions.
Thanks for quick reply:
Here is my problem in detail :-
I have a module for importing data from different sources.
There are two main interface in this module (I1,I2). I1 is for other modules by which they will access my module and I2 for inter-modules implementation's (depanding on source of imports) that can increase lateron. I want that no other module should access (or no one can use) the interface I2. Only Interface I1 and the default implementations should be visible to other module.