This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accessor Modifiers

 
Arathi Raj
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

What are accessor modifiers? Can you explain them with example.
Does static, final are accessor modifiers.

Thanks
Arathi
 
Sathya Srinivasan
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Access modifiers are the embellishments made on a variable, method, or class to define how visible they are to the outside world.

The valid modifiers are public, private, protected, and no modifier at all (sometimes referred to as default).

Here are the definitions:

public: Visible to all
protected: Visible to classes (or methods in other classes) in the same package or those that are sub-classes of the class.
private: Visible only to methods in the same class.
(default): Visible only to methods to classes in the same package.

Most of the Java beginner books explain this pretty much in-depth with examples.
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Java in General(beginner)
 
Sherry Jacob
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Arathi Raj:
Hi,

What are accessor modifiers? Can you explain them with example.
Does static, final are accessor modifiers.

Thanks
Arathi



I think Srinivasan has done most of the explaining for you.

As far as static and final are concerned, yes, they are access modifiers.
A static member is a class-wide member whereas a final member is one that cannot be modified again. In other words, final means constant.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Sherry]: As far as static and final are concerned, yes, they are access modifiers.

They are modifiers, but they are not access modifiers. Access modifier refers to public, protected, and private. (And no modifier, for "package", I suppose).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic