This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30057
    
149

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, 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
 
jQuery in Action, 2nd edition
 
subject: restricting methods access
 
Similar Threads
basic question on access modifiers and levels
access specifier and access modifier
Constructors
Access specifiers & Access Modifiers
database in netbeans