Java Reference
In-Depth Information
Method parameters
Methods are used to do some computation and then pass some value to some other methods.
When you are building a large software product then you do a small computation processing
in each of your methods and then pass some values to some other methods. This way you
will be able to create software product with small components. One of the goals of soft-
ware design is to break the entire design into small components so that complexity can be
The method we have defined as Chocolate_computation can be changed so that it can be
partitioned into 2 methods. One method will do some computation and pass some value to
the other method. This way the 2 methods can do some work which will be divided over
these 2 methods.
We can divide the 2 calculations in the Chocolate_computation method over 2 methods. Let
us try doing it.
pass_chocolates(a, b)
private int x;
x = a*b;
Return x;
chocolate_computation (){
private int a;
private int b;
private int y;
private int c;
a = 5;
b = 6;
y = Pass_chocolate (a. b)
If c >= 30 {
Else {
System.out.println( “age of the leader is below 30 and so computation not
Search WWH ::

Custom Search