Created
March 2, 2017 01:42
-
-
Save chingovan/34ac154e0476b2059a526ed291d717a1 to your computer and use it in GitHub Desktop.
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
public class SwapPointRef { | |
public static void swap(Point a, Point b) { | |
int temp = a.getX(); | |
a.setX(b.getX()); | |
b.setX(temp); | |
} | |
public static void main(String[] argv) { | |
Point c = new Point(1); | |
Point d = new Point(2); | |
System.out.println("c: " + c); | |
System.out.println("d: " + d); | |
swap(c, d); | |
System.out.println("c: " + c); | |
System.out.println("d: " + d); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment