Created
March 2, 2017 15:22
-
-
Save charlesreid1/5066680b31f4c10fdcbf1d316a07b162 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import java.util.*; | |
public class ArraysInPlace { | |
public static void main(String[] args) { | |
int x = 5; | |
System.out.println(x); | |
proofThatWeCopy(x); | |
System.out.println(x); | |
int[] y = new int[3]; | |
y[0] = 100; | |
y[1] = 200; | |
y[2] = 300; | |
System.out.println(Arrays.toString(y)); | |
noWeDont(y); | |
System.out.println(Arrays.toString(y)); | |
} | |
public static void proofThatWeCopy(int x) { | |
x = 100; | |
} | |
public static void noWeDont(int[] y) { | |
y[0] = 77777; | |
y[1] = 88888; | |
y[2] = 99999; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment