Re: Square root not working

I figured it out. I needed you put Math.sqrt. Sorry about that! :P

Re: Square root not working

In Java there's no such thing as a "global" variable/method. Thus, for methods outside of your current class (including the inheritance hierarchy) you must quantify where that variable/method came from.

Code Java:

distancePostSquareRoot = Math.sqrt(distancePreSquareRoot); // sqrt is found inside the Math class as a static method

An alternative available starting in SE 5 is something known as "static imports". This lets you do things such as importing static methods/variables and using them without needing to quantify where they come from. Note that you should be careful when using static imports.

Code Java:

import static java.lang.Math.sqrt;
public class SomeClass
{
public static void main(String[] args)
{
double a = sqrt(5);
}
}