Skip to content

Instantly share code, notes, and snippets.

@vinimonteiro
Created July 7, 2022 15:20
Show Gist options
  • Save vinimonteiro/54fe657bb9bce3704bcb86db5aba61fe to your computer and use it in GitHub Desktop.
Save vinimonteiro/54fe657bb9bce3704bcb86db5aba61fe to your computer and use it in GitHub Desktop.
Pass by value object ref 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.x=5;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment