Created
February 28, 2016 14:27
-
-
Save SanjeevMohindra/63341c3c5ac02e9423dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package callbyvalue; | |
public class ObjectCallWithCreate { | |
public static void main(String[] args) { | |
TempNum z = new TempNum(10); | |
System.out.println("Value of x before the call: " + z); | |
add(z); | |
System.out.println("Value of x after the call: " + z); | |
} | |
public static void add(TempNum z) { | |
z = new TempNum(15); | |
} | |
} | |
class TempNum { | |
public int x; | |
public TempNum(int x) { | |
this.x = x; | |
} | |
@Override | |
public String toString() { | |
return "TempNum [x=" + x + "]"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment