Tuesday, November 23, 2010

CoolTuts - Java - Methods

A method is a group of instructions that is given a name and can be called up at any point in a program simply by quoting that name.

You can write and call your own methods too. Methods begin with a declaration. Method consists of the following parts.
  1. Access Specifier
  2. public: This method can be called from anywhere. private: This method can be called or used within the class where it is defined. protected: This method can be used anywhere within the package in which it is defined.
  3. Static or Dynamic method
  4. Static methods have only one instance per class rather than one instance per object. All objects of the same class share a single copy of a static method. By default methods are not static.
  5. Return Type

No comments:

Post a Comment