Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help needed with access specifiers

 
brahmjyot singh
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 1309
10
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Campbell Ritchie
Sheriff
Pie
Posts: 50246
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to JavaRanch
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic