aspose file tools*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help needed with access specifiers" Watch "Help needed with access specifiers" New topic

Help needed with access specifiers

brahmjyot singh

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: 917

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: [] Cool your mind:[] My Sally:[]
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 36453
And welcome to JavaRanch
I agree. Here's the link:
subject: Help needed with access specifiers
Similar Threads
New way to attract indian techies
Does Scjp1.4 test AWT and IO?as I know AWT and IO will not be tested?Is it real?
What is the best data base to use?
Sun to fire 3,000 employees
Complete SCEA 5 Exam Survey /Free exam voucher $200 US Value