Reputation: 41
Kind of a noobie question but I'm curious and I can't find an answer to my question:
I have:
public class Profile
{
public void methodA(){}
}
public class User
{
private List<Profile> listProfiles;
public void test() { App.Handler.doA(listProfiles[0]);} //let's say we have 1 profile
}
public class Handler
{
public void doA(Profile) { profile.methodA();}
}
I want to restrict the use of methodA() to only my Handler Class, is it possible via a key word or some other way?
The purpose is to have everything going through the Handler.
Thanks :)
Upvotes: 1
Views: 1257
Reputation: 8091
Not possible using standard means. You can use workarounds:
Upvotes: 0
Reputation: 117220
You will have to nest Handler
inside the Profile
class and the you can make methodA
private.
Upvotes: 1