You're aware that you can draw a straight line between any two points in a plane, right? Probably, but if not, check out Euclid and his treatise called "Elements". Better yet, take this assertion on faith and write a static double getDistance(x1, y1, x2, y2) method. It should calculate the distance between two points.

# Distance between two points

- 5
Locked

Comments (12)

- Popular
- New
- Old

You must be signed in to leave a comment

Aron

8 July 2021, 20:53

under 5 min video, explaining how to calculate distance

0

Angelo Tratsis

26 April 2021, 18:15

Simplest help ever. Also for future reference

+3

Usman Full Stack Developer at QA

1 July 2021, 16:19

you legend, saved me the hassle of googling :D

+1

Karas Java Developer

1 September 2020, 22:47

Okay... wait... wait.... we are here to learn java, not quadratic mathematics.
https://www.mathwarehouse.com/algebra/distance_formula/index.php
Pythagorean Theorem in simple terms

+3

Nastya

7 May 2020, 17:03

+17

Martzehh

2 June 2020, 18:46

Thank you!!

+1

Khongpak Phupkdee

15 March 2021, 15:05

Thank you

0

Nickolas Johnson

13 March 2020, 15:29

Mathisfun.com completely screwed me on this one. I thought i was using the right formula but i guess not.

+1

Tonatiuh

19 October 2019, 18:01

Java does not have an exponent operator like some other languages. A common mistake is to assume 3^2 is 3 to the 2nd power. It is not. The caret ^ is a valid operator in Java (and similar languages), but it is binary XOR.

+3

shivani maski

26 August 2019, 08:56

Why this is showing error here ---->double Math.sqrt(double a);
^
I am getting below error:
com/codegym/task/task06/task0609/Util.java:14: error: ';' expected
double Math.sqrt(double a);

+3

Hannah Software Architect

14 January 2020, 09:00

did you changed the variables name?

+1

coffeemess

1 August 2021, 18:07

I faced the same error
you should use just Math.sqrt(double a) (without double in the beginning)

0