Java: Java Programming For Beginners a simple Start To Java Programming (Written By a software Engineer)


Download 0.82 Mb.
Pdf ko'rish
bet49/95
Sana09.01.2022
Hajmi0.82 Mb.
#261112
1   ...   45   46   47   48   49   50   51   52   ...   95
Bog'liq
Java Programming For Beginners - A Simple Start to Java Programming ( PDFDrive )

Calling A Method
For utilizing a method, it ought to be called. There are two courses in which a technique is
called i.e. technique gives back a value or nothing (no return value). The methodology of
system calling is basic. At the point when a project summons a method, the system control
gets exchanged to the called method. This called method then returns control to the guest
in two conditions. These conditions include:
Reaches the method closure brace.
Return articulation is executed.
The  methods  returning  void  is  considered  as  call  to  an  announcement.  Lets  consider  a
sample:
System.out.println(“This is the end of the method!”);
The method returning a value can be seen by the accompanying illustration:
double resultant = sumval(4.2, 2.5);
Sample Implementation:


public class Minnumber{
public static void main(string[] args) {
double x = 21.5;
double y = 2.0;
double z = minvalfunc (x, y);
System.out.println(“The returned value = ” + z);
}
public static double minvalfunc (double num1, double num2) {
double minval;
if (num1 > num2)
minval = num2;
else
minval = num1;
return minval;
}
This would create the accompanying result:
The returned value = 2.0

Download 0.82 Mb.

Do'stlaringiz bilan baham:
1   ...   45   46   47   48   49   50   51   52   ...   95




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling