Skip to content

Instantly share code, notes, and snippets.

@ajduke
Created August 19, 2012 08:23
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 ajduke/3393643 to your computer and use it in GitHub Desktop.
Save ajduke/3393643 to your computer and use it in GitHub Desktop.
public class Shape {
private void printThis() {
// prints invoking object
System.out.println(this);
}
public static void main(String[] args) {
Shape shape = new Shape();
// print the shape reference
System.out.println(shape);
// print the shape reference inside method
shape.printThis();
}
}
// after execution this will print
// Shape@19821f
// Shape@19821f
// meaning that both are similar object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment