In java for point class this kind Ouput :Point@4554617c is showing

this is the code
import java.awt.*;
Point point1 = new Point(1, 1);
Point point2 = point1;
point1.i = 2;

Assuming you used that code exactly, I would guess that the java.awt.Point class does not override the default toString method which just prints out the name of the class and a pointer to the location in memory.

That being said, the java.awt.Point class does not appear to have a public member variable called i in its Javadoc (but it does have an x member variable which may have been your intention).

Copying and pasting what you have into a Java REPL does not compile. Changing point1.i to point1.x compiles and prints java.awt.Point[x=2,y=1].

If you have a custom Point class defined locally, you would have to override the toString method to print out something useful. For example:

public class Point {
  public int x;
  public int y;

  public Point(int x, int y) {
    this.x = x;
    this.y = y;

  // Without this, it will print out something like Point@4554617c
  public String toString() {
    return String.format("Point(x=%s, y=%s)", x, y);

Do you perhaps have a Point class defined locally wherever you compiled this? Perhaps one that has a member variable i?

1 Like