Java - Packages and Access Control
You have a package
You want to allow only classes inside
tools with classes:class Helper {
void assist() {
System.out.println("Helping...");
}
}
public class Tool {
public static void main(String[] args) {
Helper h = new Helper();
h.assist();
}
}You want to allow only classes inside
tools to use Helper and its assist() method, but prevent access from outside. Which is the best way to achieve this?