Skip to content

Instantly share code, notes, and snippets.

@vinimonteiro
Created July 7, 2022 15:22
Show Gist options
  • Save vinimonteiro/ebaa411335141a0796d383bf4f322a11 to your computer and use it in GitHub Desktop.
Save vinimonteiro/ebaa411335141a0796d383bf4f322a11 to your computer and use it in GitHub Desktop.
Pass by value object ref no change original
package com.vinimo;
public class App {
public static void main(String[] args) {
Foo foo = new Foo(1);
modify(foo);
System.out.println(foo.x);
}
public static void modify(Foo foo) {
foo = new Foo(5);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment