Java Reference
In-Depth Information
When you have created a program to do some data processing, you need to save it with some
unique name. There are also some other aspects in data processing which you need to think
about. One aspect arises when you have many data processing tasks to be done as part of
one project. Each piece of code or program is wrapped under a structure element known as
a method. In procedural programming they are also known as procedures or functions. In
object oriented programming languages they are only known as methods. In object oriented
programming languages, methods do a lot of things. We will cover them in a later section.
Suppose in the example we had given above, we save our piece of code under a method
name “Chocolate_computation”. Generally in programming languages there are some pro-
gramming conventions for naming variables, methods and other programming elements. I
have used an underscore so that I have one word for the method name and yet the method
name is clear as to what it is supposed to do.
Let us wrap our code under the method name now.
chocolate_computation () {
private int a;
private int b.
private int c;
a = 5;
b = 6;
If c >= 30 {
C = a*b,
Else {
System.out.println( “age of the leader is below 30 and so computation not
Like variables, methods also are of any data type. It depends on what values the method may
return. In our case, the method is not returning a value. So it has no data type.
Search WWH ::

Custom Search