LaVOZs

The World’s Largest Online Community for Developers

'; java - Incompatible types error in Command Prompt - LavOzs.Com

I have a work about calculating the distances between two points. It consist of Point Class, Line Class as well as Main Class. The following is my Point class. After working on the private double distance(Point p) method, I am unable to return p at the public double getDistance(Point p) method. I run code on Command Prompt and it shows error: incompatible types: Point cannot be converted to double. Please advice.

class Point
{
    private int x;
    private int y;

//Constructor
public Point()
{
    //nothing
}

//Second constructor
public Point (int x, int y)
{
    this.x = x;
    this.y = y;
}

//Copy constructor
public Point (Point p)
{
    this (p.x, p.y);
}

private double distance(Point p)
{
    int dX = this.x - p.x;
    int dY = this.y - p.y;
    double result = Math.sqrt(dX * dX + dY * dY);
    return result;
}

public double getDistance(Point p)
{        
    return p;
}

//getter
public int getX()
{
    return x;
}

public int getY()
{
    return y;
}

//setter
public void set(int x, int y)
{
    this.x = x;
    this.y = y;
}

public String toString ()
{
    return String.format ("Given Point (%d, %d)", x, y);
}

}
Related
Defining an enum in Java
Install a Windows service using a Windows command prompt?
Java Point, difference between getX() and point.x
Command prompt won't change directory to another drive
Solving java.lang.NullPointerException Error Given Input from a user passed onto objects
Aliases in Windows command prompt
Object Oriented Programming with said methods. Java
How to fix runtime error and remove double for abstract class in java?