Skip to content

Instantly share code, notes, and snippets.

@gwpantazes
Created May 17, 2017 15:57
Show Gist options
  • Save gwpantazes/b260db5ed14e0b32db00148ce26a5759 to your computer and use it in GitHub Desktop.
Save gwpantazes/b260db5ed14e0b32db00148ce26a5759 to your computer and use it in GitHub Desktop.
Java final exploration of trickle down effects
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