Check out example codes for "square root of a number in java". It will help you in understanding the concepts better.

Code Example 1

Scanner in=new Scanner(System.in);
int num=in.nextInt();
System.out.println(Math.sqrt(num)); // the sqrt function gives a value in 'double' data type.

Learn ReactJs, React Native from akashmittal.com