Sunday, December 5, 2010

how can i make functions in java

In java functions are exactly same as in other langauges.
A function comprises the following things
public void functionname(int a)
{
//do any thing with int a
}
1) A function has a access modifier(public,private,protected) which can be used according to requirement.
2) return time of a function which can be any one in data types like could b strings,int, double,array any thing
3) function name which could be any thing but dont start it with numbers and special characters.
4) parameters of functions which could any number of parameters like functionname(int a,double b,int c){}
5) body of function perform any process here like add parameters multiply with constants and any thing you can do here.
*Remeber when some one ask what method signature always reply its function name and parameter list only.

No comments:

Post a Comment