1. Procedures
The procedure is a collection of expressions of algorithms useful to run a specific process. The procedure is widely known from machine language to a high level language (Query).
In the Java language procedure usually begins with the word "void". And most applications run through the procedure.
2. Functions
Functions and procedures have similarities in shape except that the function has a value which can be regenerated (Restored). The function is usually to simplify the operation. When the two procedures require a similar operation then the operation can be written into a function so that it can save time writing without having to write twice.
In the Java language functions typically begins with data types (int, char, bool). And the end of the statement, there is the word "return". Value direturn have the same value as declared in the name of the function. Consider the example of the procedures and functions of the following:
public class FunctionProcedure {
public static void main(String[] args) {
int T, n;
n = Nilai(4, 4); //Fungsi Nilai
dipanggil
T = n * 100;
System.out.println(T);
}
public static int Nilai(int a, int b) {
int n;
b = b * 2;
n = a + b;
return n;
}
}
Program may use a function that calculates the value of a and b after the calculated value of the procedure to be used by the game. and procedures play will show the result.
0 comments
Post a Comment