To get the square root of a number in Java, you can use the Math.sqrt method.
Here's an example code:
public class SquareRootDemo {
public static void main(String[] args) {
double number = 20;
double squareRoot = Math.sqrt(number);
System.out.println("Square root of " + number + " is " + squareRoot);
}
}
Output:
Square root of 20.0 is 4.472136
In the above code, sqrt method is used to find the square root of 20 and assigned to a variable squareRoot. The println method is used to output the result.