my dog learned polymorphism
The moose likes Beginning Java and the fly likes restricting methods access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "restricting methods access" Watch "restricting methods access" New topic
Author

restricting methods access

Randy Smith
Ranch Hand

Joined: Mar 27, 2011
Posts: 44
Hi guys,

how can I restrict method access to certain classes? some sample codes will be very useful
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 32499
    
214

You can use a modifier to only allow one class (private), classes in the same package (no modifier), subclasses + classes in the same package (protected) and all classes (public.)

There isn't a way to allow random methods access.


[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Randy Smith
Ranch Hand

Joined: Mar 27, 2011
Posts: 44
Jeanne Boyarsky wrote:You can use a modifier to only allow one class (private), classes in the same package (no modifier), subclasses + classes in the same package (protected) and all classes (public.)

There isn't a way to allow random methods access.


Thank you for the information
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: restricting methods access
 
It's not a secret anymore!