Distance between two points in java



Distance between two points in java..

Answer / Roushan Kumar Tiwary

To calculate the distance between two points (x1, y1) and (x2, y2) in Java, you can use the Pythagorean theorem:nn```javandouble x1 = ...;ndouble y1 = ...;ndouble x2 = ...;ndouble y2 = ...;ndouble distance = Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));n```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Java J2EE Interview Questions

What if memory allocation using new fails in C++ how to handle

1 Answers  


Distance between two points in java

1 Answers  


Find Best Job Vacancies across the world on Jooble!

0 Answers  


ALL OOPs Concepts Using Java with 1 Tiny Program – Explained!

1 Answers  


Creating Class and methods – Java OOP Exercise

1 Answers  


BIG-O NOTATIONS

1 Answers  


how to measure method execution time in java

1 Answers  


Check Your Java OOPs Concepts Skills and Master it Quickly

1 Answers  


Categories