Created
June 13, 2017 13:11
-
-
Save MericBERBER/4ae02fa48992e696bbbcba52f5db5296 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
class PassByReferenceTest { | |
public static void main(String args[]){ | |
PassByReference object = new PassByReference(); | |
System.out.println("In main method adress [1] --> " +object); | |
System.out.println("In main method value [1] --> " +object.getValue()); | |
change(object); | |
System.out.println("In main method adress [2] --> " +object); | |
System.out.println("In main method value [2] --> " +object.getValue()); | |
} | |
private static void change(PassByReference o){ | |
System.out.println("In change method adress [1] --> " +o); | |
System.out.println("In change method value [1] --> " + o.getValue()); | |
o.setValue("New Value"); | |
System.out.println("In change method value [2] --> " + o.getValue()); | |
PassByReference object2 = new PassByReference(); | |
o = object2; | |
System.out.println("In change method adress [2] --> " +o); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment