Java Reference
In-Depth Information
Scope of methods
Figure 1.9: Scope and accessibility level of methods and variables
When we create methods we use identifiers, returning value and datatype etc. For example
we can use identifier which can indicate if a method is accessible outside a class (we will
learn about classes in next section) or not. For example in Java language identifiers like
private, public, static etc. are used.
When you define your methods, you have to think whether this method should be accessible
only from inside the class in which it is created or if it can be accessible from any other
classes as well. This is one of the most important considerations for designing your code. In
object oriented programming, in some cases you need to make your methods private so that
Search WWH ::

Custom Search