Call by value in java

Call by value in java
SOURCE : CallByValue.java




public class CallByValue {


int data=10;

void change(int data){
data=data+1000;//changes will be in the local variable only
}


public static void main(String args[]){

CallByValue opr=new CallByValue();

System.out.println("before change :::: "+opr.data);
opr.change(100);
System.out.println("after change ::::"+opr.data);

}
}

INPUT





OUTPUT

before change :::: 10
after change ::::10







Sandeep Kumar D

Hi, I have written and developed this post so that most of people will be benefited. I'm committed to provide easy and in-depth tutorials on various technologies.I hope it will help you a lot.

- Sandeep Kumar D

Follow Me @Google+




SHARE

    Blogger Comment
    Facebook Comment

0 comments :

Post a Comment