Created
May 17, 2017 15:57
-
-
Save gwpantazes/b260db5ed14e0b32db00148ce26a5759 to your computer and use it in GitHub Desktop.
Java final exploration of trickle down effects
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 Ob | |
{ | |
int x; | |
Ob(final int x) | |
{ | |
this.x = x; | |
} | |
public int getX() | |
{ | |
return x; | |
} | |
@Override | |
public String toString() | |
{ | |
return super.toString(); | |
} | |
} | |
class FinalTrickleDownTest | |
{ | |
public static void main(String[] args) | |
{ | |
final Ob x = new Ob(1); | |
System.out.println("In main before mutate: " + x + " with value " + x.getX()); | |
mutator(x); | |
mutator2(x); | |
System.out.println("In main after mutate: " + x + " with value " + x.getX()); | |
} | |
static void mutator(Ob x) | |
{ | |
x = new Ob(9); | |
System.out.println("In mutator: " + x + " with value " + x.getX()); | |
} | |
static void mutator2(Ob x) | |
{ | |
System.out.println("In mutator: " + x + " with value " + x.getX()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment