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


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

Passing Parameters by Value
While working under calling procedure, contentions is to be passed. These ought to be in
the  same  request  as  their  particular  parameters  in  the  function  call.  Parameters  can  be
passed by reference or value. Passing parameters by value means calling a method with a
parameter. Through, this is the contention value is gone to the parameter.
Sample Implementation:
The accompanying project demonstrates an illustration of passing parameter by value.
public class Myswapping {
public static void main(string[] args) {
double x = 0.43;
double y = 34.65;
System.out.println(“Values of X and Y before swapping, x = ” + x + ” and y = ” + y);
myswapfunc (x, y);
System.out.println(“\nValues of X and Y after swapping: “);


System.out.println(“x = ” + x + ” and y is ” + y);
}
public static void myswapfunc (int x, int y) {
System.out.println(“Inside the function: Values of X and Y before swapping, x = ” + x + ”
y = ” + y);
System.out.println(“Inside the function: Values of X and Y after swapping, x = ” + x + ” y
= ” + y);
}

Download 0.82 Mb.

Do'stlaringiz bilan baham:
1   ...   47   48   49   50   51   52   53   54   ...   95




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