Skip to content

Instantly share code, notes, and snippets.

@t0dd
Created October 20, 2012 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save t0dd/3924185 to your computer and use it in GitHub Desktop.
Save t0dd/3924185 to your computer and use it in GitHub Desktop.
Using the java.awt.Point class to set and return an (x,y) coordinate point.
import java.awt.Point;
public class Vehicle{
private Point location = new Point();
private String name;
public Vehicle(Point location, String name){
this.location = new Point(location); //Since Point object is mutable, it should be copied.
vehicleName = name;
}
public Point getLocation(){
return new Point(this.location); //Since Point object is mutable, it should be copied.
}
}
//Java uses pass by value vs. pass by reference.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment