Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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