Skip to content
Keyhan Hadjari edited this page Sep 15, 2016 · 7 revisions

Method anatomy

Access modifier

Describes the access level of a method. The list below is ordered from lowest to highest restriction level.

  1. public can be accessed from any class.
  2. protected can be accessed from within same class, sub classes and classes within same package.
  3. Default Also called Package private, can be accessed within same class or classes in same package.
  4. private can be accessed from within same class.

Optional Modifier

  1. abstract used in abstract classes, method has to be implemented in non-abstract subclasses.
  2. final cannot be overriden in subclasses.
  3. native The method points to code written in native languages like C/C++.
  4. static Class method or variable, can be accessed without initialization.
  5. strictfp Makes floating point calculations portable.
  6. synchronized thread safe method by locking it up during usage

Return Type

The java type that is returned from the method, it could be a simple type like int or a Class object like String.

Clone this wiki locally