Calling a Method in Java



Calling a Method in Java : The methods called in java in 2 types

a) Create an object to the class to which the method belongs

syntax:

Classname obj=new Classname();
ForEx : First is a java program
then we can create and object to that class as follows:
First f=new First();
Here ‘f’ is the object of the class First

b) Then using object name.Method name(Call the method using obj.method() )

we should call the method:

Syntax:

“Obj.method();”

ForEx : Consider First is a java program

First f=new First();
Here ‘f’ is the object of the class First

f.method1();

Related Post

  • Define Precompile of Jsp page
  • What is API
  • What is JRE ? Explain
  • Explain Session tracking using Servlet
  • Why does EJB needs two interfaces
  1. 1 Trackback(s)

  2. Mar 12, 2009: forex tutorial

Post a Comment