Skip to content

Instantly share code, notes, and snippets.

@chingovan
Created March 2, 2017 01:42
Show Gist options
  • Save chingovan/34ac154e0476b2059a526ed291d717a1 to your computer and use it in GitHub Desktop.
Save chingovan/34ac154e0476b2059a526ed291d717a1 to your computer and use it in GitHub Desktop.
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