user1172635
user1172635

Reputation: 287

Return a Point value in Java

How do I return the value of a Point function. Example:

public Point myFunction(int x, int y) {
    return ???; // Want to return X and Y as a point.
}

I have no idea how the return should look. Help please.

Upvotes: 1

Views: 7086

Answers (2)

Esey
Esey

Reputation: 251

Assuming you have a constructor that accepts x and y:

return new Point(x,y);

Upvotes: 0

Oleksi
Oleksi

Reputation: 13097

Have you tried:

   public Point myFunction(int x, int y) {
        return new Point(x, y);
    }

What kind of point are you trying to make?

Upvotes: 7

Related Questions