This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Help needed with access specifiers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help needed with access specifiers" Watch "Help needed with access specifiers" New topic
Author

Help needed with access specifiers

brahmjyot singh
Greenhorn

Joined: Jan 04, 2010
Posts: 1
This is probably more of a design question.

How would we use java access specifers in designing a real world class.Java textbooks tend to give a rather rigid definition
In short i am looking for a REAL example.
salvin francis
Ranch Hand

Joined: Jan 12, 2009
Posts: 928

It depends on a scenario,

usually i prefer to use private for all class instance variables,
protected for methods (mostly not variables) that can be accessed to same package
public for methods that can be accessed every where


My Website: [Salvin.in] Cool your mind:[Salvin.in/painting] My Sally:[Salvin.in/sally]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 44563
    
  34
And welcome to JavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help needed with access specifiers
 
It's not a secret anymore!