Friday, February 13, 2015

Pass By Value

Pass by value is explained in the below example.

package Example1;

public class PassByValue {

 public static void main(String[] args) {
  // TODO Auto-generated method stub
   int x=10;
   display(x);//value of 10 is passed
   System.out.println("x value in the main method "+x);
 }

 public static void display(int a){
  a=a+1;
  System.out.println("x value in the display "+a);
 }
}

output:
x value in the display 11
x value in the main method 10
>>>Random Number Generation
------------------------------------------------------------------------------------------------------------

No comments:

Post a Comment