adspace


Distance between two points in java

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What is latest hibernate version?

486


What is the difference between equals() and == in java?

1035


What are the differences between heap and stack memory in java?

1134


What is java string pool?

1079


What do you mean by an interface in java?

1098


Can we return resultset in java?

990


Write a program to find the whether a number is an Armstrong number or not?

1095


What is difference between @controller and @restcontroller in spring?

541


explain different ways of using thread? : Java thread

1079


i want test pattern of zylog company and some examples also

2860


How is declarative handling of exceptions done in struts ?

1002


hi actully i hav form columns with origin and destination names .as like as i need to create one more column with name amount. my requirement is when i select origin and destination columns automatically i need to get amount from database.how can i. please tel me with relative code

2868


How to sort array in descending order in java?

989


Find Best Job Vacancies across the world on Jooble!

138


Is minecraft 1.15 out?

1043