|
|
|
|
|
|
|
|
|
|
|
|
|
|
JAVA PROGRAMMING
Introduction to Method A method is sub-routine containing code that operates on data member of the class. The Method Declaration At minimum, a method declaration has a name and a
return type indicating the data type of the value returned by the method: Passing Information into a Method The Method Body The method body is where all of the action of a method takes place; the method body contains all of the legal Java instructions that implement the method. Here, returnType specifies the type of data returned by the method. This can be any valid type, including class types that you create. The name of the method is specifying by name. The parameter-list is a sequence of parameters. Adding method to the Box class Let's begin by adding a method to the Box class. This program includes a method inside the box class to compute it. Here is sample program for simple method Passing parameters to a method A sample programming using returning value
|
|
||||||||
|
|
||||||||||
|
|
||||||||||
|
|
||||||||||
|
|