Mega Code Archive

 
Categories / Java Book / 002 Class
 

0136 Syntax for Method Creation

This is the general form of a method: type methodName(parameter-list) { // body of method } type specifies the returned type. If the method does not return a value, its return type must be void. The parameter-list is a sequence of type and identifier pairs separated by commas. Parameters receive the arguments passed to the method. If the method has no parameters, the parameter list will be empty